View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
David David is offline
external usenet poster
 
Posts: 3
Default Getting names of files in subdirectories

The following procedures will loop through a specified directory and
pull all the file names. Is there a way to adjust this code to loop
through a directory and all of it's subdirectories and pull the file
names and paths.

TIA

David

Sub Get_File_Names(SearchDir As String)
Dim FoundFiles
Dim FileName As String
Index = 1
FoundFiles = DirList(SearchDir)
End Sub

Function DirList(Indir As String)
Dim FileMatrix(1 To 500)
On Error Resume Next
ListFile = Dir(Indir)
'
Index = 1
Do While Not ListFile = ""
FileMatrix(Index) = ListFile
Range("SourceFiles1").Rows(Index).Value = Indir & ListFile
Index = Index + 1
ListFile = Dir()
Loop
End Function