"Find" three paragraphs?

E

Ed

In a .txt file, I have three lines repeated - it's a manually formatted
"section break", with a paragraph mark at the end of each line. When coding
Selection.Find, can I input all three lines/paragraphs at .Text = " " ?

Ed
 
K

Klaus Linke

Ed said:
In a .txt file, I have three lines repeated - it's a manually
formatted "section break", with a paragraph mark at the
end of each line. When coding Selection.Find, can I input
all three lines/paragraphs at .Text = " " ?


Hi Ed,

You can find the placeholders for these and other formatting characters in
the "Edit > Replace" dialog unter the "Special" button:
^p = paragraph mark
^m = section break

So if you'd want to search, say, for a section break followed by two
paragragraph marks, you'd use .Text = "^m^p^p".

If you want to delete part of the paragraph marks/section breaks, it may be
safer to use a wildcard replacement.

In wildcard replacements, you have to use ^13 for a paragraph mark instead
of ^p (for unknown reasons).
If you want to delete the first paragraph mark after the section break:
Find what: (^m)^13(^13) ((with "Match wildcards" checked))
Replace with: \1\2

With a wildcard replacement, you can be sure that Word won't touch the
formatting of the section break or paragraph mark. If you had replaced
^m^p^p woth ^m^p, you'd have to rely on Word to be "smart" about keeping the
formatting, which might or might not work out.

Greetings,
Klaus
 
E

Ed

Thanks, Klaus, for your help.

I have a long document that is actually several files strung together,
separated by
*****************************
*******continued***************
*****************************

So I would code:

..Text = _
"*****************************^p _
*******continued***************^p _
*****************************^p"

to Find and Replace this as a block? Or is there a better way?

Ed
 
K

Klaus Linke

.Text = _
"*****************************^p _
*******continued***************^p _
*****************************^p"


Hi Ed,

If you aren't sure about the number of stars, you might consider a wildcard
replacement (using ".MatchWildcards = True") with

..Text = "[\*]@^13[\*]@continued[\*]@^13[\*]@^13"

Greetings,
Klaus
 

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