Hi Matt,
My add-in has a need to iterate thru the document and remove any in between
blank pages before gerenating the final pdf copy . I didn't find any API that
allows manipulation of page collection in document(if there exists something
like that) .
Your observation about a "Pages" collection is correct. Since "pages" and
"lines" are something that are dynamically recalculated at the drop of a hat,
Word has no corresponding objects in its object model.
What you can do is use the GoTo method of Selection object to "walk" the pages
in the document. Start with the absolute first page, then use the option to move
to the "Next" until you get to the end. (I propose this approach since you'll be
deleting pages and they will re-number on each deleting.)
A "completely empty" page will always contain a single character* (a paragraph
mark). So to determine whether a page is empty, count the number of characters
in its Range. You can get the Range of a page using the built-in bookmark \Page.
Roughly:
Dim rng as Word.Range = ActiveDocument.Bookmarks("\Page").Range
Where the page that is picked up is always the page where the current selection
is. To delete the page, delete this range.
*Actually, it could contain more than one character, depending on how the page
break is generated. This can get complicated...
Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org
This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail