How to Display Word File Name and Path on Separate Lines
Question details
The user needs to insert a document's file name and its full file path into the text, but format them so they appear on separate lines rather than as a single continuous string.
- Product
- Microsoft Word
- Device & OS
- not provided
- Scenario
- Adding document identification details to headers, footers, or main text for archiving and printing purposes.
- Observed behavior
- By default, the Filename field with a path switch inserts the path and name on a single continuous line, requiring manual adjustment or scripts to split them.
Ensure your document has been saved to a specific location on your hard drive first; unsaved documents will not generate a valid file path when using document fields.
Use and Unlink the Filename Field
This method is ideal if the document's location is permanent and you do not need the file path to update automatically if the file is moved in the future.
By default, Word can insert the file name and path together. To split them, you must convert the dynamic field into static text by unlinking it, which then allows you to add line breaks.
Go to the 'Insert' tab, click on 'Quick Parts', and select 'Field'. In the dialog box, choose 'FileName' from the list and check the box labeled 'Add path to filename' (this adds the \p switch).
Select the newly inserted file path and name text in your document. Press 'Ctrl+Shift+F9' (Windows) or 'Cmd+Shift+F9' (Mac) to unlink the field, turning it into regular editable text.
Place your text cursor right before the file name (after the final backslash of the path) and press 'Enter' or 'Shift+Enter' to place the file name on a separate line.
Use VBA or AppleScript for Auto-Updating Fields
Use this method if you frequently move or rename documents and need the separate file name and path lines to update dynamically.
Insert File Information Easily with WPS Writer
WPS Writer provides an intuitive interface for managing document fields. You can easily insert file names, paths, and other properties without navigating complex menus.
- 1. Open the Insert Menu: Launch WPS Writer, open your document, and navigate to the 'Insert' tab on the top ribbon.
- 2. Access Document Fields: Click on 'Field' in the toolbar to open the Field dialog box.
- 3. Insert the File Name and Path: Select 'Document Information' from the category list, choose 'FileName', and check the option to include the file path.
- 4. Format the Text: Click OK to insert. If you need them on separate lines, you can highlight the text, unlink it using 'Ctrl+Shift+F9', and press Enter to split the lines.

Frequently Asked Questions
Why does my Filename field say 'Document1' instead of the file path?
This happens if the document has not been saved yet. Word cannot display a file path for a file that only exists in temporary memory. Save the document to your local drive, then right-click the field and select 'Update Field' to display the correct path.
Can I format the file name differently from the file path?
Yes. Once you unlink the field (by pressing Ctrl+Shift+F9) to convert it to regular text, you can independently apply different fonts, sizes, or colors to the file name and the file path.
How do I update the field if I move the file to a new folder?
If you have not unlinked the field, simply right-click the text and select 'Update Field', or click on the text and press F9. It will refresh to show the new folder location. If you have already unlinked it, you will need to insert a new field.




