Search for Filename and Text Within that File

L

Lance Fairway

I've been able to locate files with a macro using this:

trap: 'error trapping here
Dim iCtr As Integer

With Application.FileSearch
.NewSearch
.SearchSubFolders = True
.LookIn = "g:\client\" & Range("h6")
.Filename = "*ControlSheet.xls"
End With

With Application.FileSearch
If .Execute() > 0 Then
MsgBox ("Control Sheet with those parameters does not exist!
There are " & .FoundFiles.Count & _
" other Control Sheets for this Client ID.")
For i = 1 To .FoundFiles.Count
MsgBox .FoundFiles(i)
Next i
Else: MsgBox ("Control Sheet with those parameters does not
exist!")
End If
End With

End Sub

I need to take it a step further and locate files that also contain
specific text. Each of the files I need will have the word "UPDATING"
in cell E3. So, I want to search for documents with *ControlSheet.xls
in the title and the word "UPDATING" in cell E3.

The Windows search command can search to this level, so I figure there
must be a macro to replicate that search command.

Can anyone help?
 
Top