Find on "^" fails

E

Ed Brown

I'm trying to search for a string containing an up-carat character ("^") in
a Word document, using a Range.Find.Execute command as follows:

With wdRange.Find
.Forward = True
.Wrap = wdFindStop
.Execute FindText:="^BEG"
End With

When run, this code produces ans error 5625 (no description) on the
".Execute FindText" line. If I remove the "^" character from the FindText
string, I don't get the error. How can I search for a string containing a
"^" character? I've tried escaping it, as in "\^BEG" which produces the same
error.

Thanks in advance for any replies.
 
K

Klaus Linke

Hi Ed,

To find the caret, escape it with another caret:

.Execute FindText:="^^BEG"

You can find that in "Edit > Replace > Special".

Greetings,
Klaus
 
E

Ed Brown

That works great, thanks! I'll check "Edit > Replace > Special" if I have
any other similar situations.
 

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