R
R Avery
I've created the following function to return a list of files given a
directory path. How would I modify it to return only folders? I have
tried to supply vbDirectory as an argument to the Dir function, but that
returns both folders and files. How do I make it return only folders?
Public Function GetFileListArray(ByVal Path As String, Optional ByVal
Filter As String = "*.*") As String()
Dim DirectoryFiles() As String
Dim strFileName As String
strFileName = Dir(Path & Filter)
Do While strFileName <> ""
If strFileName <> "" Then
ReDim Preserve DirectoryFiles(Count)
DirectoryFiles(Count) = strFileName
Count = Count + 1
End If
strFileName = Dir()
Loop
GetFileListArray = DirectoryFiles
End Function
directory path. How would I modify it to return only folders? I have
tried to supply vbDirectory as an argument to the Dir function, but that
returns both folders and files. How do I make it return only folders?
Public Function GetFileListArray(ByVal Path As String, Optional ByVal
Filter As String = "*.*") As String()
Dim DirectoryFiles() As String
Dim strFileName As String
strFileName = Dir(Path & Filter)
Do While strFileName <> ""
If strFileName <> "" Then
ReDim Preserve DirectoryFiles(Count)
DirectoryFiles(Count) = strFileName
Count = Count + 1
End If
strFileName = Dir()
Loop
GetFileListArray = DirectoryFiles
End Function