VB script search for specific words - Word 2003 Documents

Hello

I'm trying to make a VBscript that searches for specific words... for example

color
center
fiber

Can anyone provide a simple function that can be given an array of words and return true if any of them are found?

The script would be run from command line in Windows, rather than as a VBA script within Word itself.

The version of Word we are using is Word 2003.

Thanks

BH
LVL 1
butterhookAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Muhammad KhanManager, ITCommented:
Dim Word
Set Word = CreateObject ("word.application")
set document = word.documents.open( "c:\workshop\worddoc.doc") 'Replace the document name with y our own
'msgbox document.name
searchWhat = inputbox ("search what? comma seperate multiple search terms")
searchWhatArray=split(searchWhat,",")
searchCount=0
found=""
foundWhat=""

With document
set tRange=.content
'msgbox .content
for x = lbound(searchWhatArray) to ubound(searchWhatArray)
'msgbox "Searching " & searchWhatArray(x)
set tRange=.content
      tRange.Find.Text = trim(searchWhatArray(x))
      tRange.Find.Execute
'      msgbox tRange.find.Found
      If tRange.Find.Found Then
            found=true
            foundwhat=foundWhat & vbcrlf & searchWhatArray(x)
            
      End If
next
if found then
 msgbox "Found " & foundWhat
end if
End With

word.quit

save it as vbs...
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
butterhookAuthor Commented:
Thanks. I'll try this out a little later and get back to you ASAP.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Word

From novice to tech pro — start learning today.