ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Looping through each directory (https://www.excelbanter.com/excel-programming/271328-re-looping-through-each-directory.html)

Jim Rech

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




All times are GMT +1. The time now is 11:58 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com