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
|