View Single Post
  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Doug Robbins - Word MVP Doug Robbins - Word MVP is offline
external usenet poster
 
Posts: 8,832
Default How do i search for multiple words in a word document?

Use the following code in a macro:

Dim search As Variant
Dim i As Long, j As Long
search = Split("fred|ted|bob", "|")
For i = 0 To UBound(search)
j = 0
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(FindText:=search(i), MatchWildcards:=False, _
MatchCase:=False, Wrap:=wdFindStop, Forward:=True) = True
j = j + 1
Loop
If j 0 Then
MsgBox search(i) & " appears " & j & " times."
Else
MsgBox search(i) & " is not present."
End If
End With
Next


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"ewar2002" wrote in message
...
I am trying to find a way to search for multiple words in word document
with
out having to do it one at a time. For example, if I wanted to search for
fred, ted, and bob how could I create a search string to find all these
words? I am not wanting to replace them with another word, just see if
they
exist in the document.

Thanks,

Ewar