Pring file path in excel

  • Thread starter Thread starter Igor
  • Start date Start date
one way:

Put this in the ThisWorkbook code module (right-click on the
workbook title bar, choose View Code, paste the following in the
window that opens, then click the XL icon on the toolbar to return
to XL):

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Dim wkSht As Worksheet

For Each wkSht In ActiveWindow.SelectedSheets
wkSht.PageSetup.LeftFooter = ActiveWorkbook.FullName
Next wkSht
End Sub

You can substitute CenterFooter or RightFooter for LeftFooter.
 
Without code, you can put this formula in any cell: =Cell("Filename")
This will give you the path and filename of the current file in the cell.
Richard Choate, CPA

Does anyone know how to have excel prints have the file
path in the print out?
 
Hi Richard,
To get the information for the worksheet your formula is on. you
want to use the cell reference
=CELL("filename",A1)

You can get the pathname information for another sheet
=CELL("filename",sheet1!A1)

The crippled form without the cell reference
=CELL("ffilename")
will give you the name of the sheet
from the last sheet update, which may be another sheetname, or even in
another workbook. For more information see
Pathname in headings, footers, and cells
http://www.mvps.org/dmcritchie/excel/pathname.htm
and you can test that for yourself.


The CELL formula is not effective until the workbook has been saved
so you have a pathname reference.
 
Back
Top