I recorded a macro to set my printer settings. I prompt the user as to whether or not they want to print the current report. Based on which report they ran, I send the Header variable to this printer setup code.
If I "run" this, the Report Header does not change from one report to the next. If I step through this code (f8) to a point 2 -3 lines past .CenterHeader = gblReportHeader and then press f5, the Report Header changes as I expect it to.
When I comment out the Application.PrintCommunication = line(s), the printpreview statement will flash the old report header and then display the proper report and header.
Any ideas why?
Sub PrintSettings(PrintZone)
' PrintSettings Macro
Application.PrintCommunication = False
With ActiveSheet.PageSetup
.PrintTitleRows = ""
.PrintTitleColumns = ""
End With
Application.PrintCommunication = True
ActiveSheet.PageSetup.PrintArea = PrintZone
Application.PrintCommunication = False
With ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = gblReportHeader
.RightHeader = ""
.LeftFooter = ""
.CenterFooter = ""
.RightFooter = ""
.LeftMargin = Application.InchesToPoints(0.7)
.RightMargin = Application.InchesToPoints(0.7)
.TopMargin = Application.InchesToPoints(0.75)
.BottomMargin = Application.InchesToPoints(0.75)
.HeaderMargin = Application.InchesToPoints(0.3)
.FooterMargin = Application.InchesToPoints(0.3)
' .PrintHeadings = False
' .PrintGridlines = False
' .PrintComments = xlPrintNoComments
' .CenterHorizontally = False
' .CenterVertically = False
.Orientation = xlPortrait
' .Draft = False
.PaperSize = xlPaperLegal
' .FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
' .Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = False
.PrintErrors = xlPrintErrorsDisplayed
' .OddAndEvenPagesHeaderFooter = False
' .DifferentFirstPageHeaderFooter = False
.ScaleWithDocHeaderFooter = True
.AlignMarginsHeaderFooter = True
End With
Application.PrintCommunication = True
' Application.Dialogs(xlDialogPrinterSetup).Show
ActiveSheet.PrintPreview
End Sub