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

ID: Q136259

The information in this article applies to:

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          : kbdta wordnt kbfield winword macword word6 word7 word95 
Version           : MACINTOSH:6.0,6.0.1,6.0.1a; WINDOWS:7.0,7.0a; winnt:6.0
Platform          : MACINTOSH WINDOWS winnt
Issue type        : kbhowto

Last Reviewed: May 24, 1999