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

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.

Forum statistics

Threads
1,223,228
Messages
6,170,875
Members
452,363
Latest member
merico17

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