Using search in VBA of Word

A

alex

Hi all,

I tried to do a search in VBA with the following code,
but cound not, the message I got is

running time error '449'
Argument not optional

What is wrong with my setting?, Thanks

Code:


Do Until wrdDoc.Bookmarks("\Sel") = _
wrdDoc.Bookmarks("\EndOfDoc")
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "COMPANY:"
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False

End With
Selection.Find.Execute

If Selection.Find.Found = True Then
MsgBox "found"
Else
Exit Do
End If
Loop
 

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