Good afternoon,
I have some help with an earlier post to do with obtaining the names of files in subfolders, however I've just discovered that there are to be subfolders for the subfolders from which I will need to extract file names! I'm at a loss of how to modify the below code to drill down another level.
Below is the code that I got from this forum that I have used to get my first level subfolder file names, could someone assist me with how I need to amend this code to get to the next subfolder level down:
Folder structure will be as follows:
Top Level Folder
sub Folder
sub sub Folder
i.e.
Archiving [top level folder]
Instant Take Ups [sub folder]
Batch Date [sub sub folder]
Any help would be most appreciated.
John
I have some help with an earlier post to do with obtaining the names of files in subfolders, however I've just discovered that there are to be subfolders for the subfolders from which I will need to extract file names! I'm at a loss of how to modify the below code to drill down another level.
Below is the code that I got from this forum that I have used to get my first level subfolder file names, could someone assist me with how I need to amend this code to get to the next subfolder level down:
Code:
Dim fso As Object
Dim fldr As Object
Dim sbfldr As Object
Dim f As Object
Set fso = CreateObject("Scripting.FileSystemObject")
Set fldr = fso.GetFolder(UserPath)
For Each f In fldr.Files
If Right(f.Name, 3) = "mdb" Or Right(f.Name, 5) = "accdb" Then
Debug.Print f.Path
End If
Next
For Each sbfldr In fldr.SubFolders
For Each f In sbfldr.Files
If Right(f.Name, 3) = "mdb" Or Right(f.Name, 5) = "accdb" Then
Debug.Print f.Path
End If
Next
Next
Folder structure will be as follows:
Top Level Folder
sub Folder
sub sub Folder
i.e.
Archiving [top level folder]
Instant Take Ups [sub folder]
Batch Date [sub sub folder]
Any help would be most appreciated.
John