J
Jac Tremblay
Hi,
I found a lot of information on that subject but I cannot get my own
procedure to work. The code is below.
I'm trying to list all the folder names and their subfolder names with a
recursive procedure. I have done that kind of job before, but i can't get
this one to work properly. I have other versions that work fine but I want to
debug this one. Can someone tell me what's wrong with it, please?
Here is the code:
' ***********************************************************
Option Explicit
Dim strPath As String
Dim fso As Object
Dim oDir As Object
Dim oDir2 As Object
Dim fsoSub As Object
Dim fSubDir As Object
Dim fSubDir2 As Object
' ***********************************************************
Sub CallingProc()
strPath = "C:\Test"
Set fso = CreateObject("Scripting.FileSystemObject")
Set oDir = fso.GetFolder(strPath)
For Each fSubDir In oDir.SubFolders
PrintFolderName strPath
Next fSubDir
Set fso = Nothing
Set fsoSub = Nothing
Set oDir = Nothing
Set oDir2 = Nothing
End Sub
' ***********************************************************
Sub PrintFolderName(strPath As String)
' Supposed to be recursive...
' Print the folder name.
Debug.Print fSubDir.Name
Set fsoSub = CreateObject("Scripting.FileSystemObject")
Set oDir2 = fsoSub.GetFolder(strPath & "\" & fSubDir.Name)
' Check subfolders recursively.
For Each fSubDir2 In oDir2.SubFolders
PrintFolderName strPath
Next fSubDir2
End Sub
' ***********************************************************
Thanks in advance.
I found a lot of information on that subject but I cannot get my own
procedure to work. The code is below.
I'm trying to list all the folder names and their subfolder names with a
recursive procedure. I have done that kind of job before, but i can't get
this one to work properly. I have other versions that work fine but I want to
debug this one. Can someone tell me what's wrong with it, please?
Here is the code:
' ***********************************************************
Option Explicit
Dim strPath As String
Dim fso As Object
Dim oDir As Object
Dim oDir2 As Object
Dim fsoSub As Object
Dim fSubDir As Object
Dim fSubDir2 As Object
' ***********************************************************
Sub CallingProc()
strPath = "C:\Test"
Set fso = CreateObject("Scripting.FileSystemObject")
Set oDir = fso.GetFolder(strPath)
For Each fSubDir In oDir.SubFolders
PrintFolderName strPath
Next fSubDir
Set fso = Nothing
Set fsoSub = Nothing
Set oDir = Nothing
Set oDir2 = Nothing
End Sub
' ***********************************************************
Sub PrintFolderName(strPath As String)
' Supposed to be recursive...
' Print the folder name.
Debug.Print fSubDir.Name
Set fsoSub = CreateObject("Scripting.FileSystemObject")
Set oDir2 = fsoSub.GetFolder(strPath & "\" & fSubDir.Name)
' Check subfolders recursively.
For Each fSubDir2 In oDir2.SubFolders
PrintFolderName strPath
Next fSubDir2
End Sub
' ***********************************************************
Thanks in advance.