WD: How to Print a Field Result on the Last Page of a Document

Last reviewed: March 10, 1998
Article ID: Q136259
The information in this article applies to:
  • Microsoft Word for the Macintosh, versions 6.0, 6.0.1, 6.0.1a
  • Microsoft Word for Windows 95, versions 7.0, 7.0a
  • Microsoft Word for Windows NT, version 6.0

SUMMARY

This article describes how to automatically place the file name of the current document (or any other field result) on the last page of every document based on the Normal template.

MORE INFORMATION

To place the file name on the last page of every document based on the Normal template, follow these steps:

  1. On the File Menu, click Open.

  2. In the List Files of Type list, click Document Templates.

  3. Select the folder where your templates are stored (for example, C:\MSOffice\Templates or C:\Winword).

  4. Click the Normal template (Normal.dot), and click Open.

  5. On the View menu, click Header and Footer.

    The first button on the left on the Header and Footer toolbar toggles between the header and footer. Toggle to the one that you want the field to appear in.

  6. Press CTRL+F9 (Windows) or COMMAND+F9 (Macintosh) to insert a field.

  7. Type the following in the field brackets

          if { page }={ numpages } "{ filename \p }"
    

    so that the field looks like this:

         { if { page } = { numpages } "{ filename \p }" }
    

    NOTE: The \p switch causes the entire path to the file name to be included.

    NOTE: The field brackets are actual fields and the code should not be copied. They should be entered as separate fields, i.e. each set of brackets corresponds to a field.

  8. On the File menu, click Save. Close the file.

The If field determines whether the current page equals the number of pages in the document. This field is present in the header or footer on every page in the document. However, the file name will be printed only on the final page of the document. These steps can be used with any field (that is, you can substitute another field code for File name if you want different results to print, such as the date).


Additional query words: repeat
Keywords : kbfield macword winword word6 word7 word95 wordnt kbdta
Version : WINDOWS:6.0,6.0a,6.0c,7.0,7.0a;MACINTOSH:6.0,6.01,6.01a
Platform : MACINTOSH WINDOWS
Issue type : kbhowto


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: March 10, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.