Hello, I've adapted the code from excelexperts a little bit but I have been trying to find out how to list only one type of file a .GHO File (ghost image), right now it lists every content in the folder/subfolders which I don't want.
I have been trying to use the Dir() VBA function but do not know if it is even correct:
Dim iRow
Sub ListFiles()
iRow = 11
Call ListMyFiles(Range("C7"), Range("C8"))
End Sub
Sub ListMyFiles(mySourcePath, IncludeSubfolders)
Set MyObject = New Scripting.FileSystemObject
Set mySource = MyObject.GetFolder(mySourcePath)
On Error Resume Next
For Each MyFile In mySource.Files
iCol = 2
Cells(iRow, iCol).Value = MyFile.Path
iCol = iCol + 1
Cells(iRow, iCol).Value = MyFile.Name
' iCol = iCol + 1
' Cells(iRow, iCol).Value = MyFile.Size
' iCol = iCol + 1
' Cells(iRow, iCol).Value = MyFile.DateLastModified
iRow = iRow + 1
Next
If IncludeSubfolders Then
For Each mySubFolder In mySource.SubFolders
Call ListMyFiles(mySubFolder.Path, True)
Next
End If
End Sub
Bookmarks