R
robot
Hello,
I have a folder consisting of Word documents, and frequently need to
retrieve files containing some given text.
So I solicit the help of VBA and cook up the following subroutine for
testing:
Sub Test()
Dim fs As FileSearch
Set fs = Application.FileSearch
With fs
.NewSearch
.FileType = msoFileTypeWordDocuments
.FileName = "*.doc"
.TextOrProperty = InputBox("Input Search String")
.LookIn = "c:\job\04\04\test\"
.SearchSubFolders = False
End with
Set fs=nothing
MsgBox .Execute()
' returns the number of files found
End Sub
In the LookIn folder ("c:\job\04\04\test\"), there are 2 doc files, each
containing the word "gobble'.
However, when I input "gobble" in the input box, the .execute method returns
0 files.
I have tried inputing "*gobble*", "gobbl*", but to no avail.
What have gone wrong?
Suggestions are most welcome!
I have a folder consisting of Word documents, and frequently need to
retrieve files containing some given text.
So I solicit the help of VBA and cook up the following subroutine for
testing:
Sub Test()
Dim fs As FileSearch
Set fs = Application.FileSearch
With fs
.NewSearch
.FileType = msoFileTypeWordDocuments
.FileName = "*.doc"
.TextOrProperty = InputBox("Input Search String")
.LookIn = "c:\job\04\04\test\"
.SearchSubFolders = False
End with
Set fs=nothing
MsgBox .Execute()
' returns the number of files found
End Sub
In the LookIn folder ("c:\job\04\04\test\"), there are 2 doc files, each
containing the word "gobble'.
However, when I input "gobble" in the input box, the .execute method returns
0 files.
I have tried inputing "*gobble*", "gobbl*", but to no avail.
What have gone wrong?
Suggestions are most welcome!