Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
ewar2002 ewar2002 is offline
external usenet poster
 
Posts: 1
Default How do i search for multiple words in a word document?

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   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



Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Word 97 in Windows XP to maintain formatting Charlie''s Word VBA questions Microsoft Word Help 22 May 20th 23 08:51 PM
Why can't I get Multiple instances of word? Laverne Microsoft Word Help 14 November 17th 06 01:35 PM
I am having difficulty with deleting headers and footers LHD New Users 5 July 24th 06 01:44 AM
WP merge file to Word sstires Tables 4 February 14th 06 06:26 PM
Word applies direct format on File open Uriel Microsoft Word Help 16 November 27th 05 07:22 PM


All times are GMT +1. The time now is 06:41 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"