Applies ToWord for Microsoft 365 Word for Microsoft 365 for Mac Word 2024 Word 2024 for Mac Word 2021 Word 2021 for Mac Word 2019 Word 2019 for Mac Word 2016

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

To view Propertiesfor a document, on Windows, choose the Filetab, choose Info, choose Properties, and then choose Advanced Properties. On Mac, choose the Filemenu, and then choose Properties.

A field codetells 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.

Syntax

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

{ FILE NAME [Switches] }

Switches

\p

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

Example

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 }

Need more help?

Want more options?

Explore subscription benefits, browse training courses, learn how to secure your device, and more.

Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.