Please Note: This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Adding a File Path and Filename.

Adding a File Path and Filename

by Allen Wyatt
(last updated July 13, 2013)


Margo wants to insert a file path and filename in an Excel worksheet. She wants to be able to insert the information in either a cell or into the header/footer. This is rather easy to do in Excel.

To insert the file path and filename into a cell, you use the CELL worksheet function in the following manner:


This formula returns the entire path, filename, and tab name of the current worksheet, like this:

E:\My Data\Excel\[Budget.xls]Sheet1

If you want to strip out the brackets and the sheet name, you can use the following variation on the formula:


The LEFT function gets rid of everything from the right bracket to the end of the string, while the SUBSTITUTE function gets rid of the left bracket.

Putting a path and filename into a header or footer is easy:

  1. Select the worksheet whose header or footer you want to change.
  2. Choose the Page Setup option from the File menu. Excel displays the Page Setup dialog box.
  3. Click on either the Custom Header or Custom Footer buttons, as desired. Word displays either the Header or Footer dialog box. (See Figure 1.)
  4. Figure 1. The Header dialog box.

  5. Position the insertion point in the Left Section, Center Section, or Right Section boxes, as desired.
  6. Click on the File button. (It looks like a file folder with a piece of paper sticking out.) Excel inserts the following code at the insertion point:
  7.      &[Path]&[File]
  8. Click on OK two times to close both dialog boxes.

When you print the worksheet, Excel replaces the codes in step 5 with the path name and the file name of the workbook, respectively.

If you are using Excel 97 or Excel 2000, then the above steps won't work. Instead, you need to use a macro to insert the path and filename:

Sub DoFullPath()
    ActiveSheet.PageSetup.CenterFooter = _
End Sub

This macro will also work in later versions of Excel. To specify a different place for the path and filename, simply change CenterFooter to another location (such as LeftFooter, RightFooter, LeftHeader, CenterHeader, or RightHeader). If you decide to use the macro approach, you will need to remember to run it every time that you change either the workbook's filename (you use Save As), or you change the place where the workbook is stored on your disk.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (2875) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Adding a File Path and Filename.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He  is president of Sharon Parq Associates, a computer and publishing services company. ...


Rounding to Even and Odd Values

Want to round values so they are always even or odd? You can do it quickly and easily by using the EVEN and ODD worksheet ...

Discover More

Finding Duplicate Documents

Over time, it is very possible to end up with multiple copies of the same document on your system. If you have (or suspect ...

Discover More

Understanding Sections

Sections are handy if you want to subdivide a document so you can apply different document formatting to those subdivisions. ...

Discover More

Excel Smarts for Beginners! Featuring the friendly and trusted For Dummies style, this popular guide shows beginners how to get up and running with Excel while also helping more experienced users get comfortable with the newest features. Check out Excel 2013 For Dummies today!


Comma-Delimited and MS-DOS CSV Variations

Excel provides different file formats you can use to export your worksheet information. One such file format is CSV, or comma ...

Discover More

Merging Many Workbooks

If you need to combine the contents of a bunch of workbooks into a single workbook, the process can get tedious. Here's a ...

Discover More

Locked File Puzzle

What would you do if every time you opened a workbook Excel told you it was locked? Here's how you can try to recover from ...

Discover More

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments for this tip:

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is eight more than 7?

2016-07-07 06:31:35



2016-03-10 07:36:21

Noel Hempseed

I am not that excel savvy. I do not follow the example.Would it be possible to illustrate simply what areas of the worksheet I would go to to put the EMy DataExcel etc in the worksheet so that it would print out at the foot of the worksheet.

Noel Hempseed

March 10, 2016

2016-01-26 08:15:26


Great site! Kudos!!! So much better than Microsoft's obtuse Help :)
Thanks for a nice contribution to all of us out here!

2014-12-02 15:09:10


I would like to customize a header for a worksheet so that I do not have to manually change it every quarter when I print a (quarterly financial)report. The four options would be First Quarter, Second Quarter, Third Quarter, and Fourth Quarter. I already have dates in the worksheet and ideally would like it to read off of that. E.g., if the date is 9.30.xx, then it would automatically print with Third Quarter. If it was 12.31.xx, then it automatically print Fourth Quarter. Can this be done?

2014-10-24 07:56:52

Michael (Micky) Avidan

("úøùéí 1") should read: ("Chart 1").
Michael (Micky) Avidan
“Microsoft® Answers" - Wiki author & Forums Moderator
“Microsoft®” MVP – Excel (2009-2015)

2014-10-24 07:25:07

Michael (Micky) Avidan

Insert a TextBox under the X Axis and run the following Macro:
Sub User_Name_Chart_Title()
ActiveSheet.ChartObjects("úøùéí 1").Activate
ActiveChart.Shapes.Range(Array("TextBox 1")).Select
With Selection.ShapeRange.TextFrame2.TextRange
.Characters.Text = "User Name: " & Environ("username")
.ParagraphFormat.Alignment = msoAlignCenter
End With
End Sub
Michael (Micky) Avidan
“Microsoft® Answers" - Wiki author & Forums Moderator
“Microsoft®” MVP – Excel (2009-2015)

2014-10-23 05:37:19


Thanks Micky,

I will work on this approach. I don't want to make the user's name equal to the chart title; I just want it to appear buried down in the footer area, near the date, time, path and file name.

Is there an equivalent term to "ActiveChart.ChartTitle.Text" but just for the Footer area? ActiveChart.Footer.Center.Text?

2014-10-22 09:13:36

Michael (Micky) Avidan

Try to run the following Macro:
Sub User_Name_Chart_Title()
For Each CH In ActiveSheet.ChartObjects
ActiveChart.HasTitle = True
ActiveChart.ChartTitle.Text = "User Name: " & Environ("username")
End Sub
Michael (Micky) Avidan
“Microsoft® Answers" - Wiki author & Forums Moderator
“Microsoft®” MVP – Excel (2009-2015)

2014-10-21 23:45:37


How can I add a user's name into the footer of an Excel chart? In other words, is there an "&[User]" element code, similar to &[Path], &[File], &[Date], etc.? This would be particularly useful in identifying charts printed from shared network files.

2014-08-15 07:22:07

Michael (Micky) Avidan

What is the EXACT function you are using ?
Michael (Micky) Avidan
“Microsoft® Answers" - Wiki author & Forums Moderator
“Microsoft®” MVP – Excel (2009-2015)

2014-08-14 08:58:34


when i am using filename function in excel 1 (this is the filename) , and then i open excel 2, the cell in excel 1 changes from "excel 1" to "excel 2".

Please advise, how to prevent this.

2013-11-10 21:50:04


In Excel 2003, I have added =CELL("filename")in cell A1 to all sheets of a workbook. The sheet name provided by this function does not change when I make a different sheet the active one. After making the different sheet the active one, I can change the sheet name by hitting F2. Is there a way to cause the sheet name to change when I activate a different sheet within the book?

2013-11-02 12:21:31


how do i keep a filepath in the footer of an excel worksheet even when email the wsheet to someone.
When emailing it changes the path to the temporary file linked to emails

Newest Tips

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.

Links and Sharing