Formatting several paragraphs

R

Raphael Goubet

Hi,

In a macro I'm writing, I have a loop on each run of which I add some
paragraphs (one or more), contained in a string variable. Now, I'd
like these paragraphs to get a LeftIndent formatting. The trouble is,
I don't know how many paragraphs I'm inserting on each run of the
loop. So, if I write:

ActiveDocument.Paragraphs.Add.Range = MyText & vbCrLf
ActiveDocument.Paragraphs(ActiveDocument.Paragraphs.Count - 1).Format
= CommentPara

were CommentPara is a ParagraphFormat object whose LeftIndent property
is set as needed, only the last paragraph of the MyText Range is
formatted.

So, my question is: who can I apply CommentPara to all the paragraphs
inserted and contained in MyText? I tried to define MyText as a Range
object, format it and then insert it with the method Add, but it
didn't work.

Thanks in advance for your help.

Raphael
 
H

Helmut Weber

Hi Raphael,
in case there is an empty paragraph at your docs end,
which probably will be there, format it as you like and
then add the new paragraphs. They will inherit the formatting
of the paragraph they are inserted in, which is the last paragraph.
If you don't have an empty last paragraph, add one beforehand.
If you want to remove it afterwards, do so.
I hope, this isn't too simple.
Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
 

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