Windows 7 - Paragraph selection and page breaks in VBA

Asked By nikkiLR on 08-Dec-09 12:17 PM

I am 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 am 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 is 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.


DaveLett replied to nikkiLR on 08-Dec-09 12:25 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 +
All manual line breaks give the _appearance_ of separate paragraphs, but in
the Word object model, those belong to the same paragraph.

Manfred F replied to nikkiLR on 10-Dec-09 06:47 AM
Hi nikki,

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