Hi All,
Been using this, but need for it to include contents within subfolders, and can't figure out how to do it.
Any one suggest the way / provide a steer?
Also, is it possible to add a column with details of the last user to save it, or access it? - not sure if that data is held with the file or not.
Thanks,
Upex
Been using this, but need for it to include contents within subfolders, and can't figure out how to do it.
Any one suggest the way / provide a steer?
Also, is it possible to add a column with details of the last user to save it, or access it? - not sure if that data is held with the file or not.
Thanks,
Code:
Dim IRowSub ListFiles()
IRow = 3 'where you want your first row of data
Call ListMyFiles(Range("a1"), False) 'Where B5 is your filepath to review contents of (eg, C:\)
End Sub
Sub ListMyFiles(MySourcePath, includesubfolders)
Set MyObject = CreateObject("Scripting.FileSystemObject")
Set mysource = MyObject.GetFolder(MySourcePath)
On Error Resume Next
For Each myfile In mysource.Files
icol = 1
Cells(IRow, icol).Value = myfile.Path
icol = icol + 1
Cells(IRow, icol).Value = myfile.Name
icol = icol + 1
Cells(IRow, icol).Value = myfile.Type
icol = icol + 1
Cells(IRow, icol).Value = myfile.Size
icol = icol + 1
Cells(IRow, icol).Value = myfile.DateLastModified
icol = icol + 1
Cells(IRow, icol).Value = myfile.Datelastaccessed
icol = icol + 1
Cells(IRow, icol).Value = myfile.Datecreated
icol = icol + 1
IRow = IRow + 1
Next
End Sub
Last edited: