Ignore page separator in VBA Find?

E

Ed

My macro does a Find Text="^p1^p^0000". It finds every instance except one.
In Normal View, there is a page separator (not a manual page break) in
between the first ^p and the 1. Apparently Find sees this separator and
rejects this instance of the text string. Is there any way to get Find to
ignore this?

Ed
 
G

Graham Mayor

The page separator shouldn't make any difference. There must be something
else. Display the formatting characters using CTRL+* and see what you have
overlooked. You can add it in a wildcard search eg the following looks for a
manual page break (^m) but you can change this for whatever is missing.

^13[1^m]{1,}^13[0]{4}

See http://word.mvps.org/FAQs/General/UsingWildcards.htm

--
<>>< ><<> ><<> <>>< ><<> <>>< <>>< ><<>
Graham Mayor - Word MVP
E-mail (e-mail address removed)
Web site www.gmayor.com
Word MVP web site www.mvps.org/word
<>>< ><<> ><<> <>>< ><<> <>>< <>>< ><<>
 
E

Ed

Thanks for the reply, Graham. I think I've solved the problem, but it was
something else. The original file is a text-only opened using Word. I've
got code to save it with " .doc" in the file name, but - silly me! - that
didn't make it Word .doc format! Plus, the SaveAs was after all the
Find/Replace. So, I put the SaveAs up front and added wdFormatDocument.
Then it found the "^p1^p" just fine and replaced it. So something in the
text-only formatting was showing up as a page separator on the screen, but
wasn't recognized as such in Word. Chalk up another learning experience.

Ed

Graham Mayor said:
The page separator shouldn't make any difference. There must be something
else. Display the formatting characters using CTRL+* and see what you have
overlooked. You can add it in a wildcard search eg the following looks for a
manual page break (^m) but you can change this for whatever is missing.

^13[1^m]{1,}^13[0]{4}

See http://word.mvps.org/FAQs/General/UsingWildcards.htm

--
<>>< ><<> ><<> <>>< ><<> <>>< <>>< ><<>
Graham Mayor - Word MVP
E-mail (e-mail address removed)
Web site www.gmayor.com
Word MVP web site www.mvps.org/word
<>>< ><<> ><<> <>>< ><<> <>>< <>>< ><<>

My macro does a Find Text="^p1^p^0000". It finds every instance
except one. In Normal View, there is a page separator (not a manual
page break) in between the first ^p and the 1. Apparently Find sees
this separator and rejects this instance of the text string. Is
there any way to get Find to ignore this?

Ed
 

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