File path in custom header.

hblatz

New Member
Joined
Oct 15, 2002
Messages
4
I would like to dynamically include the file path (along with the file name) in a customer header or footer.

I see how to do this with the file name, and the tab, but I also want to include the path so that other persons do not have to take so long to find the file. Any suggestions?
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Place this code in the ThisWorkBook module.

Private Sub Workbook_BeforePrint(Cancel As Boolean)

ActiveSheet.PageSetup.LeftFooter = ThisWorkbook.FullName

End Sub


Also, this code will place the full path in the Window title barwhen the file is opened

Private Sub Workbook_Open()
ActiveWindow.Caption = ActiveWorkbook.FullName
End Sub
 
Upvote 0
Or, try placing this in your PERSONAL macro workbook:

Sub InsertPathInFooter()
'Insert path & file name in left footer
With ActiveSheet.PageSetup
.LeftFooter = "&""Arial,Regular""&8" & ActiveWorkbook.FullName
End With
End Sub

Advantage is 1)it can be run while in any worksheet, as long as your PERSONAL workbook is open - you don't have to place the macro in each Workbook/sheet you create. 2) Makes the font smaller.

Disadvantage is that it has to be run manually, and will not insert the footer before each printing. If you change names and Save As or you save to a different path, you first have to re-run it.

What you can do, however, is, if you create a print macro, you can copy/paste the above into the appropriate section of the macro. Then, it WILL insert the current path/filename every time you print.
 
Upvote 0

Forum statistics

Threads
1,214,262
Messages
6,118,549
Members
448,835
Latest member
Profast123

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top