PDA

View Full Version : Solved: VBA To insert File Path Footer at bottom of each sheet



alu
06-13-2007, 09:18 AM
Hi, I have this code which inserts the File Path as a footer on each page of the selected sheet:

Sub Footer()
'
' footer Macro
' Macro recorded 13/06/2007 by xazz
'
'
With ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = ""
.RightHeader = ""
.LeftFooter = ""
.CenterFooter = "&Z&F"
.RightFooter = ""
.LeftMargin = Application.InchesToPoints(0.15748031496063)
.RightMargin = Application.InchesToPoints(0.15748031496063)
.TopMargin = Application.InchesToPoints(0.78740157480315)
.BottomMargin = Application.InchesToPoints(0.78740157480315)
.HeaderMargin = Application.InchesToPoints(0.31496062992126)
.FooterMargin = Application.InchesToPoints(0.31496062992126)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.PrintQuality = 600
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlLandscape
.Draft = False
.PaperSize = xlPaperA4
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = False
.PrintErrors = xlPrintErrorsDisplayed
End With
End Sub


what I would like to do is get the code to put the file path footer at the bottom of every page of every worksheet. I'm close but need help...
Thanks All...

mdmackillop
06-13-2007, 09:33 AM
Sub Footer()
Dim sh As Worksheet
For Each sh In Worksheets
sh.PageSetup.CenterFooter = "&Z&F"
Next
End Sub

mdmackillop
06-13-2007, 09:40 AM
BTW,
Unless you are changing the default settings in your code, delete all the superfluous lines, keeping only the code change that you need.

lucas
06-13-2007, 09:44 AM
If you mean to show the sheet or tab too:
.CenterFooter = "&Z&F!&A"

alu
06-14-2007, 01:19 AM
Thanks mdmackillop & lucas worked perfectly!