Word VBA >> Formatting several paragraphs

by rgoubet » Mon, 26 Jul 2004 22:34:58 GMT

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


Word VBA >> Formatting several paragraphs

by Helmut Weber » Mon, 26 Jul 2004 23:08:59 GMT


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




Word VBA >> Formatting several paragraphs

by rgoubet » Tue, 27 Jul 2004 14:15:24 GMT

Right, I hadn't thought about this!

Thanks.

Raphael




Similar Threads

1. Batch apply paragraph styles to several documents?

2. how to join several paragraphs in one?

Word XP.
I'd like to join several consecutive paragraphs one big paragraph. Is that
possible?

Thanks


3. Merge several lines into a single paragraph. - Word Document management

4. Consolidating several paragraphs into one

When scanning a document using OCR or bringing in text from a PFD document and editing it in Word, each line is formatted as a paragraph. What is the best way to consolidate these lines into a single paragraph?   

5. How do i export several paragraphs in over 25000 documents into SQ - Word Document management

6. Finding several paragraphs of text

I would like to find several paragraphs of text beginning 
and ending with certain strings where the number of 
paragraphs will not always be the same. I tried doing a 
Search using Wildcards but the best I could come up with 
was finding text when the number of paragraphs was set, 
eg, putting in the Search Box for 3 paras 
blahblah^013*^013*^013*blahblah. I don't know if this 
Search code can be refined so that there can be any number 
of paras or whether you have to do something completely 
different with VBA.

Thanks for any help.

7. detect several styles on a paragraph - Word VBA

8. How create a doc that uses paragraph from several other documents

I regularly type up building specifications/quotations which use standard 
paragraphs or groups of paragraphs. I have 20 or 30 short documents that I 
use, currently I open these docs up then cut & paste the text I need for each 
element. (EG bricks woodwork etc).

Is there a way of creating a master template that could give a series of 
drop down menus that listed the available texts?

thanks

Mark