How to insert the filename and path on the last page of a document, such that it will be updated automatically if the filename or path changes

Article contributed by Bill Coan

Insert into the header or footer a special "IF" field that looks like this:

{ IF { PAGE } = { NUMPAGES } { FILENAME \P \* MERGEFORMAT } }

Even though present on all pages, the field will cause the filename and path to appear only on the last page.

To insert the required field into your document:

1.

On the View menu, choose Page Layout (Print Layout in Word 2000)..

2.

On the View menu, choose Header and Footer.

3.

Scroll up or down (if needed) until you can see the Header or Footer in which you want the page number to appear.

4.

Click where you want the filenameto appear (could be at the beginning of a line, or just after a tab character, for instance).

5.

Press Ctrl+F9 to insert a set of field braces.

6.

Inside the braces, type the expression shown below, using arrow keys to navigate within the field and pressing Ctrl+F9 again to insert additional braces as needed:

{ IF { PAGE } = { NUMPAGES } { FILENAME \P \* MERGEFORMAT } }

7.

Select the entire field expression, starting with the first opening brace and ending with the last closing brace. Right-click the selected area and choose Toggle Field Codes. This will tell Word to hide the field code from view and display the field results instead.

8.

Click the Close button on the Header/Footer toolbar.


To Tell Word to update the field with the current results:

1.

To tell Word to update the field just before printing, click Options on the Tools menu, then choose the Print tab at the top of the dialog box and place a checkmark in the Update Fields checkbox.

2.

To tell Word to update the field immediately, view the header or footer, then right-click the field and select Update Field. (Make sure you're on the last page of your document when you do this, or there'll be nothing to see after the field is updated!).

For more information about fields, choose Field on the Insert menu. To launch the Help topic about a particular field, right-click on it and select What's This?. Word will display a definition of the field with examples of how the code can be used.