Word tasks · Headers and footers
Put a document's file name and path in its footer
A printed draft that names its own file — and the folder it lives in — can always be traced back to the master copy. This guide puts the file name, and optionally the full path, into a Word footer as a FileName field, so the footer follows the file when it is renamed or moved instead of going stale the way typed text does.
Insert the file name in the footer
Microsoft's documentation for the field codes: FileName field describes what the field inserts: the name of the current file, taken from the saved document. Because it is a field, the footer can follow the file when the file is renamed or moved — typed text cannot.
- Save the document first. The
FileNamefield reads the name the file is saved under. An unsaved document has no real name or folder yet, so save with File > Save As and give the file its final name before you build the footer. - Open the footer. Double-click in the footer area at the bottom of any page. The Header & Footer tab appears. Click where the file name should sit, or press Tab to move to the center or right tab stop.
- Insert the
FileNamefield. On the Insert tab, choose Quick Parts > Field. In the Field dialog, selectFileNamefrom the field names list. Leave the format as it is for now and select OK. The saved file name appears in the footer. - Add the full path if you need it. Repeat Quick Parts > Field, select
FileNameagain, and this time turn on the field option to add the path to the file name — the\pswitch. The footer now shows the folder as well as the name, for example a shared-drive folder followed by the file name. - Close and check a second page. Choose Close Header and Footer and scroll to another page. The same footer repeats there, because a footer belongs to the section, not to one page.
Use the plain file name on documents you send out: it identifies the file without exposing your folder structure. Use the path version on internal drafts and controlled documents, where the point is to find the master copy again — a printed page that names its own folder can be traced back to the source in seconds.
Update the field after a rename or move
A field does not watch the file system. When the document is renamed with Save As, or moved to another folder, the footer keeps showing the old result until the field is updated — updating is one keystroke, and it is the step people forget.
- Update in place. Open the footer, click the file name so the field is selected, and press F9. The field re-reads the current name and path and shows the new result.
- Update the whole document at once. Click in the body, press Ctrl+A to select everything, then press F9. Word updates the fields in the body; open the footer and press F9 there as well if the footer result still looks stale.
- See the code behind the result. Click the field and press Alt+F9. The footer shows
{ FILENAME }, or{ FILENAME \p }when the path switch is on. Press Alt+F9 again to return to the result. The\pswitch is the whole difference between the name-only and the name-and-path versions, and you can add or remove it here if you are comfortable editing field codes. - Set fields to update before printing. If these footers exist so printed copies can be traced, open File > Options > Display and, under Printing options, turn on the option to update fields before printing. Printed copies then carry the current name even if nobody pressed F9.
End state
- Every page footer shows the document's saved file name, inserted as a
FileNamefield — it shades when clicked, and Alt+F9 shows { FILENAME }. - Where the path version was chosen, the footer shows the full folder path and the field code carries the
\pswitch. - After a rename or a move, pressing F9 in the footer brings the shown name and path up to date.
- No page carries the file name as typed text that would go stale on the next Save As.
When it goes wrong
- The footer is blank or shows a temporary name. The document was not saved when the field was inserted. Save the file under its real name, then click the field and press F9.
- The path is missing even though you asked for it. The
\pswitch is not on the field. Re-insert the field with the add-path option turned on, or add\pto the field code with Alt+F9 and update with F9. - The footer still shows the old name after Save As. Fields update on demand, not on save. Click the field in the footer and press F9, or turn on update-fields-before-printing.
- The footer literally prints { FILENAME \p }. Field codes are on display. Press Alt+F9 to switch back to field results before printing.
- Only some pages show the footer. The document has more than one section, and the later section's footer is not linked to the previous one. Open that section's footer and turn on Link to Previous, or insert the field there as well.
Related document tasks
-
Add a document property and show it in the text with a field in Word
Add a document property in Word and show it in the text with a field: set Title, Manager or Company under File > Info or Advanced Properties, insert it with Quick Parts > Document Property or a property field, and refresh fields after changes.
-
Change the author name Word stamps on a document and its comments
Word signs your work with the name in its settings: new comments, tracked changes and the document Author property all take it.
-
Compress the pictures in a Word document so the file emails easily
A Word document with a dozen photos can weigh 20 MB or more, and email will refuse it — even though the pictures on the page are only a few inches wide.
-
Add a QR code or barcode image into a Word document
Add a QR code or barcode into a Word document: generate the code as an image and insert it, use a Word add-in, or use Word's built-in barcode field where it fits — then size it and test-scan the printed result.
Sources
- Microsoft Support, Field codes:
FileNamefield — what the FILENAME field inserts, and the \p switch that adds the path. - Microsoft Support, Add page numbers to a header or footer in Word — opening and working in a header or footer.