Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
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 |
Reply |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Word 97 in Windows XP to maintain formatting | Microsoft Word Help | |||
Why can't I get Multiple instances of word? | Microsoft Word Help | |||
I am having difficulty with deleting headers and footers | New Users | |||
WP merge file to Word | Tables | |||
Word applies direct format on File open | Microsoft Word Help |