calculate the current page or total pages

J

Jay Freedman

How do I programmatically calculate the current page or total pages?

Thanks

The number of the current page (if you define that as the page where
the insertion point is, regardless of whether it's on screen at the
moment) is either

Selection.Information(wdActiveEndPageNumber)

or

Selection.Information(wdActiveEndAdjustedPageNumber)

These give the same number unless the section containing the selection
has a page-number restart. In that case, the first one gives the total
count of pages from the beginning of the document, while the second
one gives the number that a {Page} field would display.

The total number of pages is similar:

ActiveDocument.Range.Information(wdActiveEndPageNumber)

In Word 2003 there is finally (!) a Pages collection, so you can ask
for

ActiveDocument.ActiveWindow.ActivePane.Pages.Count

which should give you the same number. To use this, the document has
to be in Print Layout view.
 

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