Field codes: FileName field

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 insert or provide to the document after determining the value of the field code, 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.

Security 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.


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

{ FILE NAME [Switches] }



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


To print information such as "Document: C:\MSOFFICE\WINWORD\REPORTS\Sales for QTR4.doc" on each page of a document, insert the following text and field in a header or footer:

Document: { FILENAME \p }

A subscription to make the most of your time

Need more help?

Expand your Office skills
Explore training
Get new features first
Join Office Insiders

Was this information helpful?

Thank you for your feedback!

Thank you for your feedback! It sounds like it might be helpful to connect you to one of our Office support agents.