Please Note: This article is written for users of the following Microsoft Word versions: 97, 2000, 2002, and 2003. If you are using a later version (Word 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Word, click here: Automatic Page Numbers across Multiple Documents.

Automatic Page Numbers across Multiple Documents

by Allen Wyatt
(last updated September 1, 2012)

4

Abulkalam has multiple documents that he wants to have continuous page numbering from one document to the other. If one document has an added or deleted page, then he has to manually change the page numbering in the following documents. He knows he could use master documents and subdocuments, but that can of worms is one he doesn't want to open. Abulkalam wonders if there is a way that he could avoid the need to manually change page numbers all the time.

There is no way to do this automatically in Word. You can try a workaround, by using fields within your documents, but that gets a bit complex. As an example, let's suppose that you have three documents, each representing chapters in a larger book. Chap1.doc has 15 pages, Chap2.doc has 11 pages, and Chap3.doc has 17 pages. Start by opening Chap1.doc and follow these general steps:

  1. Somewhere on the second-to-last page of the document (page 14, in this case) insert a continuous section break.
  2. Within the footer of the document's first section, press Ctrl+F9. This inserts a pair of field braces into which you should type the word PAGE.
  3. Press F9 to collapse the field you just created. This represents the page number of the current page.
  4. In the Header and Footer toolbar (it should be visible because you are working in the footer), click the Show Next button. This moves you to the footer in the last section of the document, which is after the section break you inserted in step 1.
  5. Click the Same as Previous tool so that it is not selected. This "unlinks" the footer in the last section from the footer you previously created.
  6. Delete the PAGE field in the footer. (Don't worry; the field still exists in previous pages because you unlinked this section's footer from the previous section's footer.)
  7. Press Ctrl+F9 to insert a pair of field braces into which you should type the word NUMPAGES.
  8. Press F9 to collapse the field you just created.
  9. Select the field you just created and press Shift+Ctrl+F5. Word displays the Bookmark dialog box. (See Figure 1.)
  10. Figure 1. The Bookmark dialog box.

  11. Type a simple bookmark name, such as bk. When you click Add, the bookmark is created.
  12. Close the Bookmark dialog box.
  13. Close the Header and Footer toolbar and save your document.

Now, you need to follow the same general steps in the Chap2.doc document, except that the fields you use need to be a bit more complex. Assuming that the document files are stored in the directory at C:\MyDocs\Example, you would use the following compound field in step 2:

{ ={ INCLUDETEXT "\\MyDocs\\Example\\Chap1.doc" bk \! } + { PAGE } }

What this does is use the INCLUDETEXT field to grab whatever is in the bookmark named bk from Chap1.doc (which is the total number of pages in that document) and then add the current page number to that value. Thus, numbering continues from whatever the page count was in Chap1.doc.

The field that you should use in step 7 is similarly complex:

{ ={ INCLUDETEXT "\\MyDocs\\Example\\Chap1.doc" bk \! } + { NUMPAGES } }

That's it for your Chap2.doc file; the page numbering should work just fine. In the Chap3.doc file you follow the same steps, again, using the same complex fields that you did in the Chap2.doc file. The only difference is that you reference Chap2.doc in the fields, in this manner:

{ ={ INCLUDETEXT "\\MyDocs\\Example\\Chap2.doc" bk \! } + { PAGE } }
{ ={ INCLUDETEXT "\\MyDocs\\Example\\Chap2.doc" bk \! } + { NUMPAGES } }

Note that whenever you add or delete pages from any of the documents, the page numbers within them are updated automatically when the fields are updated. (Fields are updated when you manually update them or when you choose to print or use print preview.)

There are, of course, a few "gottchas" you need to keep in mind when using this approach. First, if you delete the continuous section break (step 1) from any of the files, you will really mess things up. Second, if you move the documents to a different folder (or send them to another person who uses a different folder), then the fields won't work at all. Third, if you use multiple sections in your documents, then this approach can get quite a bit more complex as you attempt to compensate for those sections.

Another approach is to use a macro to handle the page numbering. The macro could step through all your files and set the starting page numbers to be whatever is appropriate for those files. The following is an example of such a macro:

Sub PageNumberReset()
    Dim pgNo As Long
    Dim n As Long
    Dim pathName As String
    Dim fileNames
    Dim thisFile As String
    Dim aRange As Range

    ' Specify the path to the document files
    pathName = "C:\MyDocs\Example\"
    ' Create an array holding the document file names, in sequence
    fileNames = Array("Chap1.doc", "Chap2.doc", "Chap3.doc")

    pgNo = 0
    For n = 0 To UBound(fileNames)
        thisFile = pathName & fileNames(n)
        Application.Documents.Open (thisFile)
        ActiveDocument.Sections(1).Headers(1).PageNumbers.StartingNumber = pgNo + 1
        Set aRange = ActiveDocument.Range
        aRange.Collapse Direction:=wdCollapseEnd
        aRange.Select
        pgNo = Selection.Information(wdActiveEndAdjustedPageNumber)
        Application.Documents(thisFile).Close Savechanges:=wdSaveChanges
    Next n
End Sub

To use the macro, you only have to specify the directory in which the documents are stored and put the document file names into the fileNames array. The macro sets the first document to start at page 1 and each subsequent document to start at one more than the highest page number in the previous document. If you change the number of pages in any of the documents, you'll need to rerun the macro.

If you don't want to use fields or macros to do the page numbering, you could rethink your document structure and combine all the different documents into a single document. You could also get away from Word entirely and do your page layout in desktop publishing program, such as InDesign, which is specialized to handle multiple-file page numbering.

WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (1843) applies to Microsoft Word 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Word (Word 2007 and later) here: Automatic Page Numbers across Multiple Documents.

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

Store Common Addresses in AutoText Entries

Do you write letters to lots of different people? One good place to keep those addresses is in AutoText entries. They are ...

Discover More

Protecting Tracked Changes

Track Changes is a great tool for editors and collaborators to use when creating documents. An author, seeking changes from ...

Discover More

Adding Page Numbers in Headers or Footers

While Word has a default format for page numbers, you can design and specify how you want them to appear in your document. ...

Discover More

Learning Made Easy! Quickly teach yourself how to format, publish, and share your content using Word 2013. With Step by Step, you set the pace, building and practicing the skills you need, just when you need them! Check out Microsoft Word 2013 Step by Step today!

MORE WORDTIPS (MENU)

Odd Page Numbers Disappearing

Page numbers in printed pages are often a necessary part of formatting a document. What do you do if your printed output ...

Discover More

Adding Page Numbers in Headers or Footers

While Word has a default format for page numbers, you can design and specify how you want them to appear in your document. ...

Discover More

Adding Page Numbers

Ever want to add page numbers to your document? Word allows you to control many aspects of page numbering. Here's how to add ...

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 for this tip:

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}] in your comment text. You’ll be prompted to upload your image when you submit the comment. 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 eight more than 7?

2016-10-17 04:04:27

Théophile

Hi,

Thanks for this wonderful trick. I used the footer field method. But I can see a few things to add for convenient usage of the trick:
- First, you shouldn't forget to keep open the previous file when adding the field to the present file, for example chap2 should be opened when you add the field to chap3. Otherwise, if chap2 is big, it will take time to collapse the chap3 field because it will need to open chap2 to see what is inside it.
- Second, it is not that convenient to add a continuous section break when the second to last page of your document is completely filled by an updatable field (like, it is a TOC, or a list of endnote references).
- Third, sometimes word crashes during addition of fields, probably due to the fact that it asks a lot of file opens and closes. So, don't forget to save regularly while using this feature.
- Last but not least, it should be said to people "NOT COPY PASTE THE CODE OF THE PRESENT PAGE AND UPDATE FOR YOUR SPECIFIC DATA". EACH of the {} has to be generated by using ctrl + F9. Manual typing of {} (or copy pasting of it from this website) results in {} that are not recognized by word as field limits.

Best


2016-07-19 14:11:32

Claudia

Hi9 this is what I have and it keeps pointing to Application.documents.open (thisFile)as a problem line

Sub PageNumberReset()
Dim pgNo As Long
Dim n As Long
Dim pathName As String
Dim fileNames
Dim thisFile As String
Dim aRange As Range
pathName = "C:Userscrosas-abellaDesktopPage Number folder"
fileNames = Array("Section 0a Executive Summary.docm", "Section 0b Site Description.docm", "Section 0c Utility Summary.docm")
pgNo = 0
For n = 0 To UBound(fileNames)
thisFile = pathName & fileNames(n)
Application.Documents.Open (thisFile)
ActiveDocument.Sections(1).Headers(1).PageNumbers.StartingNumber = pgNo + 1
Set aRange = ActiveDocument.Range
aRange.Collapse Direction:=wdCollapseEnd
aRange.Select
pgNo = Selection.Information(wdActiveEndAdjustedPageNumber)
Application.Documents(thisFile).Close Savechanges:=wdSaveChanges
Next n
End Sub


2015-06-24 10:27:22

Tanaporn

I'm sorry I did everything as you said but it keeps show me this message '!Syntax Error, {'. What should I do to fix this?

I'm using word 2013 on windows 8.
Thank you


2014-07-10 08:23:18

Maryke

You are a brilliant person. Thank you so much for this post, you saved me a ton of work.


Newest Tips
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.

Links and Sharing
Share