How do I find one word or phrase in a folder?

G

Guest

I cannot figure out how to search and FIND one particular word or phrase in
one particular folder. For instance, I go into Joe's folder. He has 30
sub-folders in there. I need to find a particular client. Say the folder is
misnamed. I want to search for the name BILL GATES or the phrase
multi-billionaire. I know the name or the phrase is in there somewhere, but
I don't know where.

HOW DO I SEARCH FOR AND FIND THIS? PLEASE HELP
 
A

Arvin Meyer

"difficultywithworddarlene"
I cannot figure out how to search and FIND one particular word or phrase in
one particular folder. For instance, I go into Joe's folder. He has 30
sub-folders in there. I need to find a particular client. Say the folder is
misnamed. I want to search for the name BILL GATES or the phrase
multi-billionaire. I know the name or the phrase is in there somewhere, but
I don't know where.

HOW DO I SEARCH FOR AND FIND THIS? PLEASE HELP

Here's a function you can put in a module and use from the Immediate Window:

Function SearchText(strSearch As String, strPath, strFileName As String)
' Search for text in a file
' Note: Must set a reference to Microsoft Office (version) Object Library
Dim q As Long
With Application.FileSearch
.NewSearch
.LookIn = strPath 'Path
.SearchSubFolders = True
.FileName = strFileName
.TextOrProperty = strSearch
If .Execute() > 0 Then
For q = 1 To .FoundFiles.Count
Debug.Print .FoundFiles(q)
Next
End If
End With
End Function

Then use it like this:

? SearchText("Product Key","C:\Projects\","*.txt")
C:\Projects\Arvin\Products\FrontPageData.txt
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access Downloads
http://www.datastrat.com
http://www.mvps.org/access
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top