Field codes: FileName field

Applies To
Word for Microsoft 365 Word for Microsoft 365 for Mac Word 2024 Word 2024 for Mac Word 2021 Word 2021 for Mac

Note

Field code capabilities vary by platform in Word for Microsoft 365. Some field codes can be viewed or updated in Word for Mac, but full insertion and editing may require Word for Windows desktop.

The FileName field inserts the file name of the document, as recorded on the General tab in the Properties dialog box.

To view Properties for a document, on Windows, choose the File tab, choose Info, choose Properties, and then choose Advanced Properties. On Mac, choose the File menu, and then choose Properties.

A field code tells Word what to display, such as the current date or the number of pages. Usually, the resulting value is simply displayed as part of the document. You can toggle between viewing the result or viewing the field code by pressing Alt+F9 on Windows or fn+Option+F9 on Mac.

Note

Because field codes can be visible to anyone reading your document, be sure that the information you place in field codes is not information that you want kept private.

Syntax

When you view the FileName field code in your document, the syntax looks like this:

{ FILENAME [Switches] ⁠}⁠

Switches

\p

Includes the file location, or path, with the file name.

Example

To display the document's file name and path on each page, insert the following text and field in a header or footer:

Document: ⁠{⁠ FILENAME \p ⁠}⁠