Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / April 2005

Tip: Looking for answers? Try searching our database.

calculate the current page or total pages

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jonas - 26 Apr 2005 02:22 GMT
How do I programmatically calculate the current page or total pages?

Thanks
Jay Freedman - 26 Apr 2005 05:07 GMT
>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.

--
Regards,
Jay Freedman
Microsoft Word MVP         FAQ: http://word.mvps.org
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.