Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Wildcards in the FileSearch method?

Status
Not open for further replies.

utc13

Programmer
Oct 25, 2001
43
US
I am trying to set up a file search in code using the FileSearch method (see code below). The problem I am having is this... I have a bunch of folders starting with "My", such as "My Documents", "My PDFs", etc. I want to search all of these folders at the same time however it seems that the .LookIn property doesn't support wildcards as the .FileName does. I tried setting the .LookIn to "C:\My*" but it doesn't work. I can get what I want by just setting .LookIn to "C:\" but the search then takes way too long. Can anyone help?


Set fs = Application.FileSearch
With fs
.LookIn = "C:\My Documents"
.FileName = "SomeFile.ext"
.SearchSubFolders = True
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
 
did you try this
c:\My*.*
Or
c:\My*.xxx Where xxx is the extension to seach for

DougP, MCP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top