Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel header footer question 1

Status
Not open for further replies.

mscallisto

Technical User
Jun 14, 2001
2,990
US
Word Header/Footer option has autotext variable's for "Path" and "File" while Excel has seems to only support "File"

In excel I currently manually type in the "path" then add the "File" autotext.

Is there an easy way to get the "Path" auto inserted into the excel header/footer?
 
Coopy and paste this into your VB editor. You need to save the file for it to work (no save, no path)



Private Sub Workbook_BeforePrint (Cancel as Boolean)

Activesheet.PageSetup.LeftFooter=ThisWorkbook.FullName

End Sub



Neil Berryman
IT Trainer
neil_berryman@btopenworld.com
 
No there isn't an easy way to do this.

You could write a macro to put the path into the header/footer for you, and call this from the Workbook_BeforePrint event module, to make sure the path was always up to date.

Cheers, Glenn.
 
nberryman

With the VBEditor I pasted into sheet1, saved and printed but no header.

I even added a MsgBox("Hi") at the end but it seems I'm never getting to the macro.

I saves, exited then restarted the spreadsheet and enabled macros but it seems to necer get to the macro.
 
Ok lets think of the easiest way

Right click the Sheet 1 tab and select View Code

In the left pane double click This Workbook

Paste the code there and try that

Neil Berryman
IT Trainer
neil_berryman@btopenworld.com
 
Perfect!

Strange it didn't seem to work when I originally tried to paste it in the "this workbook" space after trying "sheet1"

I'll probably never know why but it works now.

Thanks nberryman
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top