Pring file path in excel

J

J.E. McGimpsey

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.
 
R

Richard Choate

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?
 
D

Dave Peterson

You'll want to add a cell from that worksheet into that formula, else you might
not get what you really want:

=cell("filename",a1)

for instance.
 
D

David McRitchie

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top