Insert The File Path and Filename into Header or Footer

This post will guide you how to add the file path and filename into a header or footer in Excel. How do I insert the file path and filename into the current worksheet header or footer in Excel.

Insert The File Path and Filename into Header or Footer


If you want to put a file path and filename into your worksheet header or footer in Excel, you just need to use the Header and Footer tools to add it. Do the following steps:

#1 go to INSERT tab, and click Header& Footer command under Text group.

insert file path and filename header footer1

#2 click header in your worksheet, and go to DESIGN tab, click File Path and File Name commands under Header& Footer Elements group.

insert file path and filename header footer2

#3 click any cell in your worksheet, and the file path and file name will be inserted into the selected header in your worksheet.

insert file path and filename header footer3

You can also use an excel VBA macro to achieve the same result. Just do the following steps:

#1 open your excel workbook and then click on “Visual Basic” command under DEVELOPER Tab, or just press “ALT+F11” shortcut.

Get the position of the nth using excel vba1

#2 then the “Visual Basic Editor” window will appear.

#3 click “Insert” ->”Module” to create a new module

convert column number to letter3

#4 paste the below VBA code into the code window. Then clicking “Save” button.

insert file path and filename header footer4

Sub InsertFilePath() 
    ActiveSheet.PageSetup.CenterHeader = ActiveWorkbook.FullName 
End Sub

#5 back to the current worksheet, then run the above excel macro. Click Run button.

insert file path and filename header footer5

#6 Let’s see the result:

insert file path and filename header footer6

The above VBA macro will insert the file path and the file name into the center header. and if you want to insert it to other position, you can specify a different place for the path and filename, you just need to change CenterHeader  to another location, such as: CenterFooter, LeftFooter, RightFooter, Leftheader, or RightHeader.

 

Comments

So empty here ... leave a comment!

Leave a Reply

Your email address will not be published. Required fields are marked *

Sidebar