Getting a Proper Total Page Count

Written by Allen Wyatt (last updated October 13, 2023)
This tip applies to Word 2007, 2010, 2013, 2016, 2019, and Word in Microsoft 365


14

Melissa has a document that begins with a title page. She wants the pages numbered beginning with 1, but that is actually the second page of the document. (The title page isn't counted in the page count.) She got the page numbering to start correctly for her first page, but her footer now says, "Page 1 of 80," "Page 2 of 80," etc. It should only show 79 pages, again because of the title page. Melissa wonders how she can get the total page count, as shown in the footer, to be correct.

The type of page numbers that Melissa is working with are generally called "X of Y" page numbers. The X represents the current page numbers, while Y represents the total. You generally construct this type of page number in one of two ways. First, you can create your own page numbers in this way by using field codes. Assuming you already know how to add field codes to your document, the finished code would look something like this:

Page { PAGE } of { NUMPAGES }

Once collapsed, the first field code displays the current page number and the second displays the total number of pages in the document. This brings us to the second way to insert the "X of Y" page numbers—using the pre-defined page number formats in Word.

You insert these by using the Page Number tool, which can appear on various ribbon tabs. (Most notably it appears on the Insert tab of the ribbon, in the Header & Footer group, and if you are working within a header or footer, on the Design tab of the ribbon, in the Header & Footer group.) The choices presented by the Page Number tool include a Page X of Y group that provides different ways to insert the formatted page number. When you make one of these choices, the result is a field similar to the following:

Page { PAGE \* Arabic \* MERGEFORMAT } of { NUMPAGES \* Arabic \* MERGEFORMAT }

This field code looks much longer than the handcrafted one presented earlier, but it is essentially the same; it just has a few switches added for each of the field codes.

Melissa's page layout most likely includes a section break between the title page and the first real page of the document. This assumption seems appropriate since Melissa indicated that she was able to basically suppress (hide) the page numbers on the title page and have the first real page start with page 1. The problem is that the field codes use the NUMPAGES field to get the desired "X of Y" type of page numbers. If your document has only two sections in it (one for the title page and the other for the rest of the document) you can simply change the NUMPAGES field to the SECTIONPAGES field. This field returns the total number of pages in the section (the main body of the document) instead of the total page count for the document. Your field code would, essentially, look like this:

Page { PAGE } of { SECTIONPAGES }

You can make the change by simply positioning the insertion pointer in the footer, next to the page numbers, and pressing Alt+F9. This displays all the field codes in the document instead of the field code results. Just make the change to the second field, replacing the letters "NUM" with "SECTION". Press Alt+F9 again, and your page numbering should be correct, showing Page 1 of 79.

This approach will not work, however, if you have more than the single section break in your document. In that case you'll need to simply make a bit more complex change to the field codes used for the page number. Follow these steps:

  1. Position the insertion point just before the Y page number. At this point the field is probably highlighted automatically by Word.
  2. Delete the Y page number field.
  3. Press Ctrl+F9. Word inserts an empty set of field code braces.
  4. Type an equal sign and a space.
  5. Press Ctrl+F9 again. Word inserts another empty set of field code braces.
  6. Type NUMPAGES and a space.
  7. Position the insertion point just between the final two right braces.
  8. Type a minus sign and a 1. Your field code for the Y page number should now look very similar to this:
  9. { = { NUMPAGES } - 1 }
    
  10. Press Shift+F9 to collapse the fields.

This approach works because you are subtracting 1 (the length of the title page) from the total number of pages in the document. Thus, you end up with Page 1 of 79.

The two approaches discussed so far work great if you are going to be modifying the document and know that the length of your main body will change over time. If this assumption is not correct—if your document is static and it will never have less or more than 79 pages—then you can skip messing with the field code and simply type a static page count for the Y page number. (Just make sure you delete the field code for the Y page number first.)

WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (5882) applies to Microsoft Word 2007, 2010, 2013, 2016, 2019, and Word in Microsoft 365.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Working with Document Links

Word makes it easy to establish links between documents. Here's how to change and manage those links easily.

Discover More

Table Header Rows after a Manual Page Break

Insert a manual page break into the middle of a table, and you may find that subsequent pages of the table don't always ...

Discover More

Editing a Building Block Entry

Once you've created a Building Block, you may believe that it is "set in stone" and cannot be changed. Not so! You can ...

Discover More

Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!

More WordTips (ribbon)

Understanding the Gutter Margin

Most everyone knows that Word allows you to set top, bottom, left, and right margins for your document. There is another ...

Discover More

Two Page Numbering Schemes in the Same Document

Word is great at numbering pages if you only need a single, consistent numbering scheme through the document. If you need ...

Discover More

An Exact Number of Lines Per Page

For some purposes, you may need to fit an exact number of lines on a printed page. This may be easier said than done, as ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is two more than 7?

2024-01-29 16:17:49

cjs

Thanks Alan - I am subscribed to your tips for word and excel and always find useful information - this one saved me a ton of time as I edit lots of big documents with lots of section breaks!


2023-01-12 10:54:11

PJ

Thank you! This is exactly what I was looking for. It took 1 minute to fix my document after spending 30 minutes going in circles on other websites.


2022-01-31 13:39:49

Prue

I believed that I already understood Sections. I believed that I already understood insertion of fields. But getting the page numbers (in footer in my case) to coincide with Sections (rather than total pages in whole document) was defeating me. THANK YOU!!!


2021-11-27 02:48:05

kaikey

Thank your help very much !


2021-11-15 10:03:40

Andrew

To deal with more complicated situations, like Rory mentions below for documents with multiple sections, and also to skip preliminary matter at the beginning of a document (not just cover pages, but also tables of contents and other preliminary matter--which may have its own numbering), and also attachments at the end of a document (e.g., exhibits to a contract which may have their own numbering), I let Word do the work via the following expedient: insert a bookmark at (or near) the end of some text that must occur on the last page, and in the "Page X of Y" footer reference bookmark the last page ("Y") by a cross-reference to the bookmark's "Page Number" (*not* its Bookmark Text). Et voila.


2021-11-14 13:41:40

neon

Allan,
Just discovered you while looking to find ways to handle complicated page breaks

THANK YOU
You have done a GREAT job of both showing and explaining why you solutions work.

Neon


2021-10-07 21:23:45

Rory

Is it possible to terminate the counting without using SectionPages?
If the document contains a landscape page, the SectionPages won't work.

I have many documents that need to terminate the counting before the Appendix.
In some cases, I may include landscape pages within my document for very large tables.


2021-06-08 09:19:52

J.S.

This was extremely useful! Thank you for the help!


2021-04-30 12:41:08

Paul Moran

That is Awesome!!!
Thank you for the help.


2021-03-03 11:59:45

Dave

Hi there, how do you get the page numbers to be correct when you have hidden pages within a merge field?

for example:

If you have 10 pages in total, page 1 is the introduction so no page number needed and page 2 - 3 have merge fields attached to them and therefore are only visible in some instances.

If I use page number X of Y the page numbers are only correct if all 10 pages are visible. If say page 2 is not visible as the merge field has not opened it in this instance then the page number will read 1 of 9 when actually it should be 1 of 8 as the intro page is not included in the numbering and page 2 is not relevant?

I hope this makes sense?


2020-07-30 14:06:56

Joseph

This was clutch!


2020-05-21 15:49:23

Rachel

Thank you, Mr. Wyatt! You, sir, are the bomb.


2020-03-04 13:02:54

Rabbbitvillain

It's so awesome that you are still running this website. You've helped me heaps before, and now 10 years later, again.

Thanks for what you do!


2019-10-18 08:32:04

Krondor

Thanks for the coding Allen

Has made my life so much easier since stumbling upon your tips web page.


This Site

Got a version of Word that uses the ribbon interface (Word 2007 or later)? This site is for you! If you use an earlier version of Word, visit our WordTips site focusing on the menu interface.

Videos
Subscribe

FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.