ExcelBanter

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

Tom Ogilvy

Looping through each directory
 
Sub tester2()

With Application.FileSearch
.NewSearch
.LookIn = "C:\My Documents"
.SearchSubFolders = True
.Filename = ".xls"
.MatchTextExactly = True
.FileType = msoFileTypeExcelWorkbooks

If .Execute() 0 Then
MsgBox "There were " & .FoundFiles.Count & _
" file(s) found."
For i = 1 To .FoundFiles.Count
MsgBox .FoundFiles(i)
Next i
Else
MsgBox "There were no files found."
End If
End With

End Sub


Pretty much does what you describe including the find files.

You may have to use it to get a gross list, then loop the list
(.foundfiles) to cull out the substrings you want.

Regards,
Tom Ogilvy


"Steven Revell" wrote in message
...
Hi all,

I'm looking for a way to loop through all the directories
on a server and run find files (without subdirectory
searching).

I would like it to run on Excel 97 but Excel 2000 will be
fine.

So my questions is does anyone know how to run through all
the subdirectories within a directory. And, if those
directories have sub directories then go through them as
well.

thanks for any help,

Steven




Steven Revell

Looping through each directory
 
Cheers guys,

My problem is that there are a lot of files and filesearch can only do a
maximum of 65000 or so. There are about 2 million and so thats why i
need to do a find files on each separate directory.

Thanks,

Steven Revell
Applications Development & Support

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


All times are GMT +1. The time now is 12:53 AM.

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