Written by Allen Wyatt (last updated April 5, 2022)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365
When you open a workbook in Excel, the workbook name is displayed in the title bar. At times, it would be nice to display more than a simple workbook name in the title bar. Many people could profit by a way to display a full path name along with the workbook name in the title bar. Unfortunately, Excel does not provide a way to do this easily.
If you only need to know the full path name once in a while, then you can create a very simple macro and assign it to the QAT or a shortcut key. When you run the macro, the information in the title bar for the active window is changed to reflect the full path name. This macro, called ChangeCaption, is as follows:
Sub ChangeCaption() ActiveWindow.Caption = ActiveWorkbook.FullName End Sub
The only drawback to this approach is that whenever you rename your workbook by saving it under a different name, the new file name (and path) are not updated in the title bar unless you rerun the macro.
Note:
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (7850) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365. You can find a version of this tip for the older menu interface of Excel here: Full Path Names in Excel.
Save Time and Supercharge Excel! Automate virtually any routine task and save yourself hours, days, maybe even weeks. Then, learn how to make Excel do things you thought were simply impossible! Mastering advanced Excel macros has never been easier. Check out Excel 2010 VBA and Macros today!
If you try to open a second workbook and you see an error message, it could be because of the way you are opening the ...
Discover MoreWhen you save your workbooks, Excel can also save a preview image (thumbnail) that can be displayed in the Open dialog ...
Discover MoreWhen storing your Excel workbook, you need to specify a file name to be used for the workbook. Take a moment to consider ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
2022-04-08 09:58:11
J. Woolley
@Kiwerry
A commonly used abbreviation here in America is RTFM, which translates roughly to "Read the freaking manual." I'm happy you found something useful n My Excel Toolbox. Notice it is available as an Excel add-in (MyToolbox.xlam), which avoids copy/paste issues and makes it available to each workbook you open, including access to the Insert Function (Shift+F3) and My Toolbox Macros (Ctrl+M) dialogs.
2022-04-08 05:18:09
Kiwerry
@ J. Woolley: Thanks for the quick clarification.
My apologies. A commonly used saying here in Germany translates roughly to "Those who can read have an advantage". I had actually visited your site and downloaded the toolbox a week or so ago, but not yet installed anything. On reading your comment I opened the module in a text viewer, copied the function out and pasted it into a module, as you diagnosed.
Thanks too for the Chip Pearson link. After reading that I removed and exported the module, used a text editor to uncomment and slightly amend (added your name to the description) the attributes, and re-imported it. The syntax error is gone and the edited description showed up correctly in the Object Browser.
2022-04-07 10:09:40
J. Woolley
@Kiwerry
Thank you for visiting My Excel Toolbox. As stated there: After reviewing a module's .bas file, "you should use VBE's File > Import File... (Ctrl+M) rather than copy/paste, so the text file's Attribute statements are properly incorporated." Attribute statements are added to a module when it is exported/imported. You can delete them if you copy/paste individual procedures.
See http://www.cpearson.com/excel/CodeAttributes.aspx
2022-04-07 09:11:15
Kiwerry
@ J. Woolley: Thank you.
I immediately installed the NameOf function, but when I ran it the two attribute statements following the Function statement threw a syntax error without showing a description or an error number. The function worked once I commented them out.
Environment: W10 machine, Excel 365.
'Attribute NameOf.VB_Description = "Return Target's Worksheet.Name, Workbook.Name, or Workbook.Path; or return app/environment information as text."
'Attribute NameOf.VB_ProcData.VB_Invoke_Func = "
14"
2022-04-06 10:09:31
J. Woolley
My Excel Toolbox includes the following function to return information about Target (a cell or range):
=NameOf([This], [Target])
The first parameter This can be "sheet" (or "worksheet"), "book" (or "workbook"), "path" (or "filepath"), "app" (or "application"), "caption" (or "titlebar"), "statusbar", "user", "organization", "printer", "computer", "?" (or "help"), or the name of an environment variable (like "TEMP"). This function is similar to Excel's CELL and INFO functions, but perhaps more useful.
See https://sites.google.com/view/MyExcelToolbox/
2022-04-05 11:27:44
Cindy
If you want just the path:
=LEFT(CELL("Filename",$A$1),FIND("[",CELL("Filename",$A$1))-1).
I do not make any claim to authorship for this; it surely was in another version of one of these tip emails
2022-04-05 04:33:15
Kiwerry
The function
=CELL("filename")
will return the full filename; an additional bonus is the sheet name at the end of the string.
Apologies to those for whom this is "coals to Newcastle".
2018-06-04 21:02:52
Julie
You can always add to your page layout for reporting purposes (or just to look at if you are using). Go to Page Layout tab, click the little arrow at the right bottom corner of Page Setup, choose Header/Footer tab, the Custom Footer, and maybe in the right section put your cursor and add the Insert File Path (little folder icon)/Insert File Name (Excel icon). Now you can always see it if you print it out.
2018-06-04 12:15:02
Steven
It is also possible to add the filename to one's Quick Access Toolbar. Select Customize QAT, More Commands. On the list on the left, under Choose Commands From, select Commands Not in the Ribbon. Choose Document Location.
This will always show the path for the current file in the QAT. Depending on how many commands you have in your QAT and your window size, this path listing may be truncated.
2018-06-03 09:39:23
Rhonda Landry
I don't know if this is at all helpful (I'm more of a beginner user), but I wanted to be able to add the full-path name of my current file to my list of files to work on later, so I added the file's full-path to the Quick Access Toolbar. One must click the name to be able to see the actual path (and perhaps arrow over a bit), so it's a bit of a pain, but it is easy for me to click on the name, copy, then paste where I need it. To do this (for other beginners): > File > Options >Customize > Commands Not in Ribbon > Document Location > Add, OK. Thank you so very, very, very much for your tips, and to all the commenters, from an avid learner :-)
2018-06-02 08:30:18
Dave
The other drawback is there is not enough room title bar to show the path if you have other commands there. It would be nice to have it display at the end of the line with the commands tabs since there is more space there.
Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2023 Sharon Parq Associates, Inc.
Comments