View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Jim Rech Jim Rech is offline
external usenet poster
 
Posts: 2,718
Default Looping through each directory

The the FileSearch object:

Sub FileSearchExample()
Dim fs As FileSearch
Dim i As Integer
Set fs = Application.FileSearch
fs.LookIn = "c:\windows"
fs.FileName = "shell32.*"
fs.SearchSubFolders = True
If fs.Execute 0 Then
For i = 1 To fs.FoundFiles.Count
MsgBox fs.FoundFiles(i)
Next i
Else
MsgBox "No files were found"
End If
End Sub

--
Jim Rech
Excel MVP