Hi all
I have a macro which prints the active sheet in A3 format.
However when the same code is attached to the back end of another macro (which creates the sheet) it prints A4.
I don’t understand why?
I have rearranged, modified, checked the net but no success.
Any help much appreciated.
Regards
Mark
I have a macro which prints the active sheet in A3 format.
Code:
Sub PrintPlan ()
' Setup page to print 17 columns 1 page wide A3 portrait
'
' Keyboard Shortcut: Ctrl+Shift+P
Dim LR As Long
Application.ScreenUpdating = 0
Application.PrintCommunication = False
LR = Range("A" & Rows.Count).End(xlUp).Row
With ActiveSheet.PageSetup
.PrintArea = "A1:P" & LR
.LeftMargin = Application.InchesToPoints(0.1)
.RightMargin = Application.InchesToPoints(0.1)
.TopMargin = Application.InchesToPoints(0.3)
.BottomMargin = Application.InchesToPoints(0.5)
HeaderMargin = Application.InchesToPoints(0)
.FooterMargin = Application.InchesToPoints(0)
.PaperSize = xlPaperA3
.Orientation = xlPortrait
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 2
End With
Application.PrintCommunication = True
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, IgnorePrintAreas:=False
End Sub
However when the same code is attached to the back end of another macro (which creates the sheet) it prints A4.
Code:
'Print Parameters
Dim lr As Long
Application.ScreenUpdating = 0
Application.PrintCommunication = False
With ActiveSheet.PageSetup
lr = Range("A" & Rows.Count).End(xlUp).Row + 50
.PrintArea = "A1:P" & lr
.LeftMargin = Application.InchesToPoints(0.1)
.RightMargin = Application.InchesToPoints(0.1)
.TopMargin = Application.InchesToPoints(0.3)
.BottomMargin = Application.InchesToPoints(0.5)
HeaderMargin = Application.InchesToPoints(0)
.FooterMargin = Application.InchesToPoints(0)
.PaperSize = xlPaperA3
.Orientation = xlPortrait
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 2
End With
Application.PrintCommunication = True
'Option to print, then close
MSG1 = MsgBox("Would you like to print a copy?", vbYesNo, "Print page")
If MSG1 = vbYes Then
‘Ive also tried with the ‘Print Parameters to AppPrintComTrue section in here
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, IgnorePrintAreas:=False
Application.DisplayAlerts = False
ThisWorkbook.Close SaveChanges:=False
Application.ScreenUpdating = True
Else
Application.DisplayAlerts = False
ThisWorkbook.Close SaveChanges:=False
Application.ScreenUpdating = True
End If
End Sub
I don’t understand why?
I have rearranged, modified, checked the net but no success.
Any help much appreciated.
Regards
Mark