Software

Display a Word document's full path in the title bar

Displaying a Word document's name and full path in the title bar can be helpful -- and a little VBA will quickly take care of the job.
When you open a new document, Word displays a generic name in the title bar -- documentx. Once you give the document a meaningful name (by saving it), Word updates the name in the title bar. However, in both cases, Word displays only the filename. It won't display the full path to the document.

Fortunately, most of us don't care what's in the title bar, but for if you do, VBA is your answer. A simple macro will update the contents of the title bar to display the document's name and path. To add this macro to a document (you can also add it to the Normal.dot template so that every new document you create includes the macro), do the following:

  1. With the file open, press [Alt]+[F11] to open the Visual Basic Editor (VBE).
  2. Add the following auto macro to the This Document module:Sub AutoOpen() 'Display document name and path in the title bar. ActiveWindow.Caption = ActiveDocument.FullName
    End Sub

     

  3. Return to the Word document, then save and close it.
  4. Open the document. This will trigger the auto macro, which displays the document's full pathname in the title bar.

The security setting could delay the display, but only temporarily. With all but the lowest setting, Word prompts you to enable macros when you open the document. As soon as you do so, Word will run the auto macro and update the title bar. Since this is an auto macro that runs only when you open the document, Word won't update the contents in the title bar when you save the file. If that's a problem, add a second macro to respond to your save tasks. Open the document's module and add the following macro to ThisDocument: Sub FileSaveAs() 'Display document name and path in the title bar. If Dialogs(wdDialogFileSaveAs).Show = 0 Then Exit Sub System.Cursor = wdCursorNormal ActiveWindow.Caption = ActiveDocument.FullName End Sub You'll need both macros for a complete fix: The first macro updates the title bar when you open the document and the second updates when you rename the document.

About

Susan Sales Harkins is an IT consultant, specializing in desktop solutions. Previously, she was editor in chief for The Cobb Group, the world's largest publisher of technical journals.

17 comments
rekeene
rekeene

Hi, I'm really glad to have found this most useful macro. I've seen this feature in WordPerfect and always liked it. What I would like to know if is the file and path name can also show up using the Save command as it does with SaveAs. Thanks. Ellie

PerryNZ
PerryNZ

I got it to work, by following Susan's instructions. Then I tried to do just the same for the Normal.dot template. Then, when I attempt to re-open the Word file with which I was first successful, I get this error message. Microsoft Visual Basic Compile error: Member already exists in an object module from which this object module derives. After lots of trying, I disabled macros and implemented RodsMine's suggestion, above. But it annoys me that my success was so fleeting. W XP OS, BTW.

Essyweb
Essyweb

It has been a nice post it was very knowledgeable.Thanks for that. college papers

pflores
pflores

You can also put the Document Location command on the Quick access Toolbar so you don't have the security issue. And this works for all MS Office applications.

nrobin
nrobin

Got a compile - syntax error.

Shane A.
Shane A.

Great fix, but does that have to be done on a 'per document' basis, or is it global once tweaked? And if it is global, does it affect existing and newly created documents?

krpc
krpc

As they read now, the macro comments start with a single left quote (`) instead of a quote ('). Word 7 reports these macros as errors as typed. To fix the problem, the left quotes should be changed to quotes after pasting the macros into Word's Visual Basic Editor.

ssharkins
ssharkins

Post the code, we'll take a look at it.

ssharkins
ssharkins

There's no way to add it to all existing documents other than to just open them and add the code. If you want it in all new documents, add it to Normal.dot.

LLL3
LLL3

Great tip, I have LONG wanted to do this, just assumed I could not. THANKS! I just put it in my normal.dot (Word 2003, haven't tested 2007 yet) and it worked like a charm on any open document. It needs to be in a regular code module though, not the ThisDocument module, if you put it in Normal. Choose Tools, Macros, Macros, Type 'AutoOpen' as the name, then click Create if you don't already have a regular code module for Normal.

Essyweb
Essyweb

I really enjoy reading the articles on this blog.It was very interesting!!! college papers

ssharkins
ssharkins

I apologize. I keep disabling smart quotes but they continue to show up where I least want them!

Carla
Carla

Thank you so much. How can I make this happen for my Excel 7 documents ?

peter.burtenshaw
peter.burtenshaw

Try something like this Works in XL from '95 to 2003; should work in 2007 also. Sub Windowtitle() With ActiveWorkbook If .Windows(1).Caption = .FullName Then .Windows(1).Caption = .Name Else .Windows(1).Caption = .FullName End If End With End Sub

RodsMine
RodsMine

In Word/Excel(/others?), View>Toolbars, Web adds an "address" field that displays the current path and title of the document on the toolbar. You can then use Tools>Customize to drag it to where you want it to be on the toolbar.

rms10
rms10

You can find the address location by displaying the document properties.

Ron_007
Ron_007

Thanks for the command bar tip. I looked for equivalent in Word 2007 with no luck. It may be there somewhere, "hidden" but I couldn't find/recognize it. Word 2010 (beta) is half way there. If you add a new group to existing tab (or new tab and group) look in "all commands" for an "Address" command with a little drop down arrow icon. It shows the path, but if it is too long you don't see the whole path or file name (but you can click in it and scroll around to either end). But that puts it just in one tab (at a time). The drop down displays a list of folders you have accessed, and if you select one it opens the folder in Explorer. The "best" place for it would be the QAT. Unfortunately, the command does not appear to be in the list available to the QAT (boo, somewhat inconsistent). with a lot of luck they'll fix it before GA in June.