path in headers ie (c:\my documents\filename.xls


Posted by JTG on January 30, 2001 12:01 PM

What I really want is to combine the location (path), filename using : =cell("filename"),
With the date and with the
page # of __ Pages on each page.

I do not think you can get location i.e., C:\My Documents\JGG\filename.xls to print in Headers, but would love to know how, if you can.

If anyone does know how to get path to print in headers/footers, please share the tip.

You can get the path to print by placing this: =cell ("filename") in any cell
BUT I can’t seem to uncover the command line to also include the stuff you can include in headers & footers (like date, page, pages, etc).

Posted by Dax on January 30, 2001 1:02 PM

The way to do this is with a (very) small piece of VBA code. Go into your workbook, open the VB editor (Alt + F11), double click on the ThisWorkBook on the Project Explorer and enter the following:-
Private Sub Workbook_BeforePrint(Cancel As Boolean)

ActiveSheet.PageSetup.LeftFooter = ThisWorkbook.Path & _
"\" & ThisWorkbook.Name & " " & "&D " & _
"&P of &N"

End Sub


This will add the full workbook path, the date and the Page 1 of x that you wanted.

Posted by JTG on January 30, 2001 4:50 PM

This works GREAT - my thanks to DAX!!

Thank-you

PS - If you know how to make the dafault NEW workbook (File New) open with this already embedded; that would be even greater!
(Word uses Normal.dot but I can not find documentation on Excel or Excel's equal to Normal.dot in Word)
What I would really love to do is by default have any new workbook opne with this as a header or footer and also a few other tweeks (like Top, bottom, Left Right margins, etc.)



Posted by Dax on January 31, 2001 1:33 PM

Re: Add this to all default workbooks

If you open a new workbook and add the code to it, then save it as the template "Book" in the folder XLStart (normally in Windows/Application Data/Microsoft/Excel) you will find that all of your default template will now show path names, etc on printed sheets.

Regards,
Dax