Testing for blank pasges in document

R

red6000

Hi,

Is there a way to loop through each page in a document to test if it is
blank (ignoring header/footer) and if it is blank to remove the page?

Thanks.
 
J

Jezebel

1. Pages don't exist as such in the Word object model: they are artifacts of
the formatting, not containers.

2. A page cannot be completely blank (other than pages inserted at print-out
as a consequence of next even/odd page section breaks). There must be at
least one paragraph for the page to exist at all.

That said, yes it would be possible to find empty paragraphs that exist in
isolation on a page of their own, and to delete them. Is this something you
need to do often? Can't see that using VBA is going to help you much here: I
think you'd have to visually examine the document anyway to check the
consequences of the deletion. In which case, you might as well do the whole
exercise manually.
 
E

Ed

1. Pages don't exist as such in the Word object model: they are artifacts of
the formatting, not containers.

2. A page cannot be completely blank (other than pages inserted at print-out
as a consequence of next even/odd page section breaks). There must be at
least one paragraph for the page to exist at all.

That said, yes it would be possible to find empty paragraphs that exist in
isolation on a page of their own, and to delete them. Is this something you
need to do often? Can't see that using VBA is going to help you much here: I
think you'd have to visually examine the document anyway to check the
consequences of the deletion. In which case, you might as well do the whole
exercise manually.








- Show quoted text -

I cobbled together something once to iterate through the pages of a
document and save each page out as a new file.

One thing I would think you must determine before you delete is: why
is that page blank? Was the document composed on a computer with a
different printer driver than yours, reformatting the pages and
putting blanks where there weren't before? Are there some styles or
other formattings keeping paragraphs from flowing smoothly? Did some
kind of file conversion leave a bit of junk on the page that's messing
with the pagination?

Maybe if you can tell us what you;re dealing with, we can take a
better shot. Otherwise, turn on Show All and look at each page and
decide if you want to delete it or not.

And when you do try something, please try it on a COPY of your
important work. Nothing bites more than making a mistake in a macro
and you can't catch it to stop it before it hits ActiveDocument.Save
at the end!

Ed
 
R

red6000

Thanks for the replies.

My vba system creates a letter package using userforms.

As a general rule, the package is then sent to a default printer that prints
duplex. Now due to the duplex, the code will insert a double page break so
that parts of the package appear on a total new page as opposed to the back
of the 'current' page.

However, the user will have an option to print on another printer, which
unfortunately isn't duplex capable and therefore when the same pack is
printed on the non-duplex printer they end up with an 'extra' blank page. So
what I'm trying to do is if they choose ro print on teh other printer (which
should be rare), that the code iterates through the document and removes the
double page break.

hope that makes sense.

Thanks for the help.
 

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