I am using this section of code to go through a known directory, and put subdirectory names into lists, as well as filenames within the directories.
Sub ListFilesAndSubFolders(fld As Object)
Dim fil As Object
Dim sfl As Object
For Each sfl In fld.SubFolders
Me.List3.AddItem UCase(sfl.Name) ' Puts directory name in list
ParseFolder2 "k:\Documents" & "\" & sfl.Name ' Puts all files found in
main direcotory in another list
ParseFolder3 "k:\Documents" & "\" & sfl.Name ' Puts Subdirectory names in another list
Next sfl
End Sub
Sub ParseFolder3(FolderName3 As String)
Dim fso As Object
Dim fld As Object
Set fso = CreateObject("Scripting.FileSystemObject")
Set fld = fso.GetFolder(FolderName3)
Call ListFilesAndSubFolders3(fld)
End Sub
Sub ListFilesAndSubFolders3(fld As Object)
Dim fil As Object
Dim sfl As Object
For Each sfl In fld.SubFolders
Me.List3b.AddItem sfl.Name
Next sfl
End Sub
This all works, however if there are two directories both containing the same files, it lists the first set directories in accending order but when it lists the second duplicate set of subdirectory names they are listed in descending order?
Any ideas, thanks
Sub ListFilesAndSubFolders(fld As Object)
Dim fil As Object
Dim sfl As Object
For Each sfl In fld.SubFolders
Me.List3.AddItem UCase(sfl.Name) ' Puts directory name in list
ParseFolder2 "k:\Documents" & "\" & sfl.Name ' Puts all files found in
main direcotory in another list
ParseFolder3 "k:\Documents" & "\" & sfl.Name ' Puts Subdirectory names in another list
Next sfl
End Sub
Sub ParseFolder3(FolderName3 As String)
Dim fso As Object
Dim fld As Object
Set fso = CreateObject("Scripting.FileSystemObject")
Set fld = fso.GetFolder(FolderName3)
Call ListFilesAndSubFolders3(fld)
End Sub
Sub ListFilesAndSubFolders3(fld As Object)
Dim fil As Object
Dim sfl As Object
For Each sfl In fld.SubFolders
Me.List3b.AddItem sfl.Name
Next sfl
End Sub
This all works, however if there are two directories both containing the same files, it lists the first set directories in accending order but when it lists the second duplicate set of subdirectory names they are listed in descending order?
Any ideas, thanks