VB Code:
Public Function RecurseFolderList(FolderName As String) As Boolean
On Error Resume Next
Dim fso, f, fc, fj, f1
Set fso = CreateObject("Scripting.FileSystemObject")
If Err.Number > 0 Then
RecurseFolderList = False
Exit Function
End If
On Error GoTo 0
If fso.FolderExists(FolderName) Then
Set f = fso.GetFolder(FolderName)
Set fc = f.Subfolders
Set fj = f.Files
'For each subfolder in the Folder
For Each f1 In fc
'Do something with the Folder Name
Debug.Print f1
'Then recurse this function with the sub-folder to get any'
' sub-folders
RecurseFolderList (f1)
Next
'For each folder check for any files
For Each f1 In fj
Debug.Print f1
Next
Set f = Nothing
Set fc = Nothing
Set fj = Nothing
Set f1 = Nothing
Else
RecurseFolderList = False
End If
Set fso = Nothing
End Function