
Searching untill the end of the word file
Hi Koen,
To avoid going past the end of the file with a Find, set the Wrap property
of the Find object to WdFindStop.
The following example searches forward through the document for the word
"aspirin." If the word "aspirin" is found, it's selected. If the end of the
document is reached, the selection point doesn't move.
With Selection.Find
.Forward = True
.ClearFormatting
.MatchWholeWord = True
.MatchCase = False
.Wrap = wdFindStop
.Execute FindText:="aspirin"
If .Found Then
MsgBox "text found"
Else
MgsBox "text not found"
End If
End With
Regards
Jonathan West - Word MVP
MultiLinker - Automated generation of hyperlinks in Word
Conversion to PDF & HTML
http://www.multilinker.com
Word FAQs at http://www.multilinker.com/wordfaq
Please post any follow-up in the newsgroup. I do not reply to Word questions
by email
Quote:
>When searching a character at a document, word starts again at he top of
>the document. Word gives the message that he did come to the end off the
>file but he places the cursor back at the top of the document. How can
>we discover that we passed the end of the file. Which code in VBA tell's
>us that the end off the fille was reached while searching a specifique
>character.