Back
Word

Shortcuts for getting the filename and path into your document

On my post about how to add the file name and path to a header or footer, Steven asks a good question:

“Is there a way to save this into a shortcut for future use?”

I’ve found a few ways to do this:

  • You can save the field code in your Header gallery or your Footer gallery.
  • You can save the field code as AutoText.
  • You can create a macro that will insert the correct field, and you can add a button that runs the macro on the Quick Access Toolbar.

In each case, it will look like you’re saving your document’s name as a shortcut, but really you’re saving the field code. When you press ALT+F9, the field code looks like this.

File name field code

Note: This is a really long post–so if you know you want the button, skip ahead to the section on creating a macro.

Option 1: The Header or Footer gallery

After you insert the FileName field into your header or footer, select the field (it will say the name of your document), but don’t select the paragraph mark.

Click Header or Footer, and then click Save Selection to Header Gallery or Save Selection to Footer Gallery.

Add the FileName field to the gallery

The upside? It’s easy to do. The downside? You need to scroll to the bottom to find your new gallery entry.

Option 2: The Filename field as AutoText

This begins the same way: After you insert the FileName field into your header or footer, select the field (it will say the name of your document), but don’t select the paragraph mark.

On the Insert tab, in the Text group, click Quick Parts, and then click Save Selection to Quick Part Gallery.

Add the FileName field to Quick Parts

In the dialog box that opens, type a name that you’ll remember, and then in the Gallery list, click AutoText. (You can choose any gallery, but AutoText seems to be a shorter shortcut.)

Adding the FileName field to AutoText

The upside? It’s also easy to do. The downside? You still need to click Quick Parts and point to AutoText and find your gallery entry–which isn’t that much faster than inserting the field.

Option 3: Create a macro

You can use this procedure to create other shortcut buttons, too.

Double-click in the header area or the footer area.*

On the View tab, in the Macros group, click Macros and then click Record Macro.

Record a macro to add the FileName field

Type a name (without any spaces) and then click the Button button.

The button option for macros

In the Word Options dialog box, click the name of your macro, and then click Add to add it to the Quick Access Toolbar.

If you want to change how the button looks, click Modify and choose a new button.

Click OK.

Now, insert the FileName field.

Then click the View tab again, click Macros, and click Stop Recording.

When you click the new button on the Quick Access Toolbar, Word will insert the FileName field.

Enjoy your shortcuts!

– Joannie Stangeland

* If the double-click action isn’t working for you, you can click Insert, click Header or Footer, and then click Edit Header or Edit Footer.