Paragraph selection and page breaks in VBA

  • Follow


Hi,

I'm looping through the paragraphs in a document (i.e. For Each myPara In 
ActiveDocument.Paragraphs) and looking at the style, length of paragraph and 
a number of other things. The trouble I'm having is when two paragraphs are 
separated by a page break rather than a paragraph mark: then VBA recognises 
it as only one paragraph.

Is this "expected" behaviour? I assume that it's a case of my understanding 
of a page break being different to Word's. And does anyone know of a 
(preferably) quick and easy way to overcome this so that VBA recognises it as 
two paragraphs? I could go through and insert a paragraph mark with each page 
break but I wondered if there was a more elegant solution out there...

Many thanks in advance for any help.

Nikki
0
Reply Utf 12/8/2009 5:17:01 PM

Hi Nikki,
Is it expected behavior? Well, that depends, when you write "page break" do 
you mean a "manual line break" (which you insert by pressing SHIFT + ENTER) 
or do you really mean a page break (which you insert by by pressing CTRL + 
ENTER).
All manual line breaks give the _appearance_ of separate paragraphs, but in 
the Word object model, those belong to the same paragraph.

HTH,
Dave
0
Reply Utf 12/8/2009 5:25:01 PM


Hi nikki,

> I'm looping through the paragraphs in a document (i.e. For Each myPara In 
> ActiveDocument.Paragraphs) and looking at the style, length of paragraph and 
> a number of other things. The trouble I'm having is when two paragraphs are 
> separated by a page break rather than a paragraph mark: then VBA recognises 
> it as only one paragraph.

there are also issues wiht hidden text, especially when paragraph marks are 
included. Always show hidden text, when You iterate through paragraphs..

Manfred
0
Reply Utf 12/10/2009 11:47:01 AM

2 Replies
1055 Views

(page loaded in 0.002 seconds)


Reply: