Search

VBA to Loop Through All Sub-folders


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
sub DoFolder_Test()
Dim FileSystem As Object Dim HostFolder As String HostFolder = "C:\" 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 Dim File For Each File In Folder.Files ' Operate on each file Next End Sub

No comments:

Post a Comment

Note: only a member of this blog may post a comment.