Extract file details from folder and subfolders - VBA

jwb1012

Board Regular
Joined
Oct 17, 2016
Messages
167
Hi everyone - I found this great code below that extracts the file names for all files in my folder. I was wondering if anyone knows how to also add the: "file path"; "file size"; "last modified date"; and "last modified by".

Please let me know if you have any thoughts!


Code:
Sub Auto_Open()
  Dim FileSystem As Object
  Dim HostFolder As String
    HostFolder = "C:\Users\e314704\Desktop\LCST Gain Share\Reports"
    
  Set FileSystem = CreateObject("Scripting.FileSystemObject")
  DoFolder FileSystem.getFolder(HostFolder)
End Sub
Sub DoFolder(Folder)
  Dim SubFolder
  For Each SubFolder In Folder.SubFolders
    DoFolder SubFolder
  Next
  i = Sheets("File Extraction").Cells(Rows.Count, 1).End(xlUp).Row + 2
  Dim File
  For Each File In Folder.Files
    Sheets("File Extraction").Hyperlinks.Add Anchor:=Cells(i, 1), Address:= _
        File.Path, TextToDisplay:=File.Name
    i = i + 1
  Next
End Sub
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.

Forum statistics

Threads
1,214,861
Messages
6,121,971
Members
449,059
Latest member
oculus

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top