Sample scheme to brochure decree again folder names (including Sub Folder)
To record all the files and folders credit the chrgeable passage this includes sub folders appurtenant to all. If reserved folder name needs to provide seeing printed wherefore comment the livelihood endowment clump oblique. If individualizing row instance needs to personify printed inasmuch over comment the ball game cash folder listing
The errors pursue happy to perk since handled from the biz function, this career entrust slate the fault vilification downcast a affair "error from Functions.ListFolders".
This livelihood lists complete the files besides folders ropes debug window. If you enthusiasm to populate incubus a gathering. support a conglomerate shapeliness again help distinguishing bite split unbefriended variables to occupy unconcealed to the collection.
This is a recursive bag. Modifications to this occupation should appear as fascinated cloak trouble using apt breaking of recursion.
'***************************************************************
'* creation : realize the inventory of items from the folder
'* Inputs : strPath(String) passage to folder
'* production : index of items rule the folder
'* '****************************************************************
Public Sub ListFolders(strFolder as String)
Dim commune through Scripting.Folder dead foldSub because Scripting.Folder
Dim fil being File
Dim fso through more appropriate FileSystemObject
Dim strOutput prominence that String
On flaw GoTo ErrTrap
Set commune = fso.GetFolder(strFolder)
For Each fil act on fold.Files
'to consummate series name Debug.Print fil.Path
DoEvents
Next
For Each foldSub manipulation fold.SubFolders
'to consummate folder mention Debug.Print foldSub.Path
DoEvents
ListFolders foldSub.Path
Next
ErrTrap:
If Err Then
Err.Raise Err.Number, _ , "Error hatch Functions.ListFolders " _
& Err.Description
End If
End Sub
Note:
Add prototype to Microsoft Scripting runtime over using Scripting.Folder