Is word Found?

J

jesse

when we use find (ctrl F) in word, how to check if anything is found programmatically
and how many words are found

regards
 
D

Doug Robbins - Word MVP - DELETE UPPERCASE CHARACT

' a Macro to occurences of a word
' Macro created Saturday, July 03, 1999 by Doug Robbins
'
Dim Message, Title, Default, MyValue
Dim Counter as Long

Message = "Enter the word for which you need the number of occurences" '
Set prompt.
Title = "InputBox Demo" ' Set title.
Default = "" ' Set default.
' Display message, title, and default value.
MyValue = InputBox(Message, Title, Default)
Selection.HomeKey Unit:=wdStory
With ActiveDocument.Content.Find
.MatchWholeWord = True
Counter = 0
Do While .Execute(FindText:=MyValue, Forward:=True) = True
Counter = Counter + 1
Loop
End With

MsgBox "The word " & MyValue & " appears" & Format(Counter) & " times."

--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.
Hope this helps
Doug Robbins - Word MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top