Function FolderSet(FolPath)
' finds all folders in path FolPath
' WARNING - UNCOMMENT NEXT TWO LINES IF
' FSO NOT DECLARED IN MAIN BODY
' Dim FSO
' Set FSO = CreateObject("Scripting.FileSystemObject")
Dim Fol, strTemp, aFols(), oFolder, subFolder, aTmp, i
ReDim aFols(-1)
Set oFolder = FSO.GetFolder(FolPath)
For Each Fol In oFolder.SubFolders
ReDim Preserve aFols(UBound(aFols) + 1)
aFols(UBound(aFols)) = Fol.Path
Next
'Recurse through all of the folders
For Each subFolder In oFolder.subFolders
aTmp = FolderSet(subFolder)
For i = 0 To UBound(aTmp)
ReDim Preserve aFols(UBound(aFols) + 1)
aFols(UBound(aFols)) = aTmp(i)
i = i + 1
Next
Next
FolderSet = aFols
End Function
' finds all folders in path FolPath
' WARNING - UNCOMMENT NEXT TWO LINES IF
' FSO NOT DECLARED IN MAIN BODY
' Dim FSO
' Set FSO = CreateObject("Scripting.FileSystemObject")
Dim Fol, strTemp, aFols(), oFolder, subFolder, aTmp, i
ReDim aFols(-1)
Set oFolder = FSO.GetFolder(FolPath)
For Each Fol In oFolder.SubFolders
ReDim Preserve aFols(UBound(aFols) + 1)
aFols(UBound(aFols)) = Fol.Path
Next
'Recurse through all of the folders
For Each subFolder In oFolder.subFolders
aTmp = FolderSet(subFolder)
For i = 0 To UBound(aTmp)
ReDim Preserve aFols(UBound(aFols) + 1)
aFols(UBound(aFols)) = aTmp(i)
i = i + 1
Next
Next
FolderSet = aFols
End Function