Hello All
I am hoping someone can help on this please
One of our members kindly gave me this code which works great
The only issue is I want to ignore any folders that have "Closed" as the name in any folder but I don't know how to change the code
[Public Sub ScanSubfolders()
Dim FileSystem As Object
Dim HostFolder As String
Range("A1").Select
HostFolder = "S:\Branch Data\Test\folder\open\Open"
Set FileSystem = CreateObject("Scripting.FileSystemObject")
DoFolder FileSystem.GetFolder(HostFolder)
End Sub
'---------
Sub DoFolder(Folder)
'---------
Dim SubFolder
Dim oFile
For Each SubFolder In Folder.SubFolders
'Debug.Print SubFolder
DoFolder SubFolder
Next
For Each oFile In Folder.Files
' Operate on each file
' Debug.Print Folder, oFile.Name, getFileProperty(oFile, 5)
ActiveCell.Value = Folder
ActiveCell.Offset(0, 1).Value = oFile.Name
ActiveCell.Offset(0, 2).Value = oFile.DateLastModified
ActiveCell.Offset(1, 0).Select 'next row
Next
End Sub]
I am hoping someone can help on this please
One of our members kindly gave me this code which works great
The only issue is I want to ignore any folders that have "Closed" as the name in any folder but I don't know how to change the code
[Public Sub ScanSubfolders()
Dim FileSystem As Object
Dim HostFolder As String
Range("A1").Select
HostFolder = "S:\Branch Data\Test\folder\open\Open"
Set FileSystem = CreateObject("Scripting.FileSystemObject")
DoFolder FileSystem.GetFolder(HostFolder)
End Sub
'---------
Sub DoFolder(Folder)
'---------
Dim SubFolder
Dim oFile
For Each SubFolder In Folder.SubFolders
'Debug.Print SubFolder
DoFolder SubFolder
Next
For Each oFile In Folder.Files
' Operate on each file
' Debug.Print Folder, oFile.Name, getFileProperty(oFile, 5)
ActiveCell.Value = Folder
ActiveCell.Offset(0, 1).Value = oFile.Name
ActiveCell.Offset(0, 2).Value = oFile.DateLastModified
ActiveCell.Offset(1, 0).Select 'next row
Next
End Sub]