Is there a way to specify that FSO.GetFolder return the list of folders in numerical sort order? The module I just created works just fine, but the names found are not sorted numerically.
Code:
Public Function DirFolders(strDirectory As String, Optional Req As String)
'*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
' Find the names of folders in a directory. Optionally, restrict
' the names returned to folder names that contain a sub-string.
' In either case, the names are returned as a semicolon delinated
' list.
'*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
Dim objFSO As Object
Dim objFolders As Object
Dim objFolder As Object
DirFolders = ""
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolders = objFSO.GetFolder(strDirectory).SubFolders
For Each objFolder In objFolders
If Not IsMissing(Req) Then
If InStr(objFolder.Name, Req) > 0 Then _
DirFolders = DirFolders & objFolder.Name & ";"
Else
DirFolders = DirFolders & objFolder.Name & ";"
End If
Next objFolder
Set objFSO = Nothing
Set objFolders = Nothing
Set objFolder = Nothing
End Function