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?
 

Some videos you may like

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.

lenze

Legend
Joined
Feb 18, 2002
Messages
13,690
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
 

Barry Katcher

Well-known Member
Joined
Feb 25, 2002
Messages
4,053
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.
 

Watch MrExcel Video

Forum statistics

Threads
1,122,187
Messages
5,594,748
Members
413,930
Latest member
Nela817

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
Top