Searching untill the end of the word file 
Author Message
 Searching untill the end of the word file

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.

  koen.verspecht.vcf
< 1K Download


Sat, 09 Nov 2002 03:00:00 GMT  
 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.



Sat, 09 Nov 2002 03:00:00 GMT  
 Searching untill the end of the word file
Hi Koen,

Set the Wrap property of the Find object as follows:

Selection.Find.Wrap = wdFindStop

--
Hope this helps.
Regards
ibby

Please post replies or follow-ups to the **newsgroup** so that participants
may benefit or contribute.


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.



Sat, 09 Nov 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. When Exiting my VB program it leaves the access lock file .LDB behind untill Re-booted

2. Word appends numbers at the end of my saveAs file in VBA

3. End-Of-File Word macro ???

4. Looping till end of Word file

5. Searching a word file with VBA?

6. Word searching files, with data from a cell in excel

7. Searching for a word in HTML files.

8. Search whole word from a text file

9. SEARCH IN TEXT FILE ON WHLE WORD,,

10. Keyword Search on MS Word and Text Files

11. How to search word(s) in external files?

12. Keyword Search on MS Word and Text Files

 

 
Powered by phpBB® Forum Software