Finding Start and End of Paragraph

M

ML

I need some way to be able to find the start and end of paragraphs in a
document via code. I want to be able to loop through them all and insert a
starting and ending character on each.

How can this be done?

Also is it possible to determine the start and end page of a paragraph that
spans pages?
 
J

Jezebel

ML said:
I need some way to be able to find the start and end of paragraphs in a
document via code. I want to be able to loop through them all and insert a
starting and ending character on each.

Dim pPara as word.paragraph
For each pPara in ActiveDocument.Paragraph

pPara.InsertBefore ...
pPara.InsertAfter ....

Next


How can this be done?

Also is it possible to determine the start and end page of a paragraph
that spans pages?

pPara..Range.Characters(1).Information(wdActiveEndPageNumber)
pPara..Range.Characters(pPara.Range.Characters.Count).Information(wdActiveEndPageNumber)
 
K

Klaus Linke

And if you want to insert the character before the ¶ mark:

pPara.Range.Characters.Last.Previous.InsertAfter ....

Or do a wildcard replacement
Find what: ([!^13]@)(^13)
Replace with: $\1§\2
(with $ being inserted at the beginning and § at the end)

Regards,
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