I'd like to search through a large number of word files all held in the same folder, searching each document for a keyword.
When a document is identified which contains the keyword the script should output the document file name to a text file report.
So far I have created the following script which searches specified word docs for set terms. This script is obviously hardcoded for specific files, if you could demonstrate how to make it search all ".doc"
files in the folder that would be great. It also does not create the text file report.
Set objWord = CreateObject("Word.Application")
objWord.Visible = True
Set objDoc = objWord.Documents.Open("L:\STSMP00001.docx")
Set objSelection = objWord.Selection
objSelection.Find.Forward = True
objSelection.Find.MatchWildcards = True
objSelection.Find.Text = "presentation"
Do While True
objSelection.Find.Execute
If objSelection.Find.Found Then
strWord = objSelection.Text
strWord = Replace(strWord, "[[", "")
strWord = Replace(strWord, "]]", "")
Wscript.Echo strWord
Else
Exit Do
End If
Loop
Set objWord = CreateObject("Word.Application")
objWord.Visible = True
Set objDoc = objWord.Documents.Open("L:\STSMP00002.docx")
Set objSelection = objWord.Selection
objSelection.Find.Forward = True
objSelection.Find.MatchWildcards = True
objSelection.Find.Text = "presentation"
Do While True
objSelection.Find.Execute
If objSelection.Find.Found Then
strWord = objSelection.Text
strWord = Replace(strWord, "[[", "")
strWord = Replace(strWord, "]]", "")
Wscript.Echo strWord
Else
Exit Do
End If
Loop