SBendBuckeye
Programmer
I am using the FileSystemObject and spinning through the Drives collection and then processing the Subfolders and Files collections with code similar to the following. How many levels can you nest with a recursive call. I don't want to blow the call stack and I don't know in advance how many levels of subdirectories a given client user may have set up.
Thanks in advance for any help and/or suggestions!
'Skip A drive and other removable drives
If drv.IsReady Then
For Each fld In .RootFolder.SubFolders
If Not fld Is Nothing Then
Call ProcessFolder(fld)
End If
Next fld
End If
Private Sub ProcessFolder(pfldFolder As Folder)
Dim fld As Folder
Dim fil As File
On Error Resume Next
'Process any files for this folder
For Each fil In pfldFolder.Files
'Do some processing
Next fil
'Make recursive call with subfolder collection
For Each fld In pfldFolder.SubFolders
Call ProcessFolder(fld)
Next fld
Set fld = Nothing
Set fil = Nothing
On Error GoTo 0
End Sub 'ProcessFolder
Thanks in advance for any help and/or suggestions!
'Skip A drive and other removable drives
If drv.IsReady Then
For Each fld In .RootFolder.SubFolders
If Not fld Is Nothing Then
Call ProcessFolder(fld)
End If
Next fld
End If
Private Sub ProcessFolder(pfldFolder As Folder)
Dim fld As Folder
Dim fil As File
On Error Resume Next
'Process any files for this folder
For Each fil In pfldFolder.Files
'Do some processing
Next fil
'Make recursive call with subfolder collection
For Each fld In pfldFolder.SubFolders
Call ProcessFolder(fld)
Next fld
Set fld = Nothing
Set fil = Nothing
On Error GoTo 0
End Sub 'ProcessFolder