Hi
I don't have the right code with me as it's on my work PC but the below is close.
There is nothing wrong wit the code as it works fine, but the only issue is when I run it at first I get a runtime error and that wont go away until I for on file -> print -> page setup
once I go on page setup and close it the code runs fine.is there a reason for this and if you know it is there a way to fix it.
Thank you
I don't have the right code with me as it's on my work PC but the below is close.
There is nothing wrong wit the code as it works fine, but the only issue is when I run it at first I get a runtime error and that wont go away until I for on file -> print -> page setup
once I go on page setup and close it the code runs fine.is there a reason for this and if you know it is there a way to fix it.
VBA Code:
With ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = "&F"
.RightHeader = ""
.LeftFooter = ""
.CenterFooter = "Page &P of &N"
.RightFooter = ""
.LeftMargin = Application.InchesToPoints(0.25)
.RightMargin = Application.InchesToPoints(0.25)
.TopMargin = Application.InchesToPoints(0.5)
.BottomMargin = Application.InchesToPoints(0.5)
.HeaderMargin = Application.InchesToPoints(0.25)
.FooterMargin = Application.InchesToPoints(0.25)
.PrintGridlines = True
.Orientation = xlLandscape
.FirstPageNumber = xlAutomatic
.FitToPagesWide = 1
Thank you