Correct "NumPages"?

Does exists some solution for correct display of number of pages in the document with different first page for Word 2007 and newer and for unlimited number of users?

If you're using the "Different First Page" option in the Header & Footer Tools tab, that has no effect on the result of the NumPages field -- although the header or footer on the first page may appear different from the header or footer on other pages, the page count is not changed.

However, if you've inserted a section break and restarted the page numbering in the section following the break, then the page number on the last page of the document won't be the same as the total number of pages displayed by the NumPages field. There are two possible field constructions that will display the last page's number.

The simpler method is to insert a bookmark (or a Set field, which creates a bookmark) on the last page of the document. Let's assume you name the bookmark LastPage, although it can be any valid bookmark name. Then, in a header or footer, you can replace the NumPages field with the field {PageRef LastPage}. That will display the same number as would a {Page} field on the last page. The drawback of this simple procedure is that a bookmark, being invisible, is easily deleted by accident if the text containing it is deleted or overwritten; then the PageRef field will display an error message.

The other method depends on knowing exactly the number of pages in the first section, before the section break. Let's say the first section (cover page, table of contents, etc.) has 5 pages. Then you can edit the header/footer to change the NumPages field as follows:

  • Insert an equal sign before the NumPages field.
  • After the NumPages field, insert a minus sign (use the hyphen key) and the number of pages in the first section (in this example, type the number 5).
  • Select the whole thing, from the equal sign to the number, and press Ctrl+F9 to insert a pair of field brackets around it. It should now look like {={NumPages}-5}.
  • Press F9, or right-click the field and click Update Field.

This method doesn't use a bookmark that could be deleted, but its drawback is that the result will be wrong if the number of pages in the first section changes, for example if the table of contents grows longer.

You could combine the two methods, putting the bookmark at the end of the first section instead of the end of the document, and then making the field construction {={NumPages}-{PageRef LastPage}}.

_____________________________
https://jay-freedman.info

26 people found this reply helpful

·

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

Thank you for your answer, but incorrect display of number of pages really exists in "simple layout" with no section break. That error is just visual (if the document is edited, print-previewed, etc., number is automaticaly corrected), but users, who just view document, can see incorrect number. (I do not know, how it arise – when the document is edited, number of pages on first page is correct, but when it is saved and re-opened, number of pages on first page is "1" …incorrect displaying probably depends on version of application, complexity of document content, etc.)

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

Jay's solution works if you follow the directions. Following his directions, if you don't have a Section break, you could use a field coded as:

{={NumPages}-1 \#0}

Note: The field brace pairs (i.e. '{ }') for the above example are created in the document itself, via Ctrl-F9 (Cmd-F9 on a Mac); you can't simply type them or copy & paste them from this message. Nor is it practicable to add them via any of the standard Word dialogues.

Cheers
Paul Edstein
(Fmr MS MVP - Word)

4 people found this reply helpful

·

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

Thank you for your answer. I followed your (and Jay's) directions, but incorrect display still persists, just with little difference – after using „{={NumPages}-1 \#0}“ is number of pages on first side decreased by one then before (however, i realize that decreasing is probable result of my wrong use of field code).

1 person found this reply helpful

·

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

Perhaps then you should explain what you think the display should show. I take you are putting these field codes on the second page, and not on the first page?
Cheers
Paul Edstein
(Fmr MS MVP - Word)

2 people found this reply helpful

·

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

 
 

Question Info


Last updated April 14, 2025 Views 17,924 Applies to: