Option Explicit

Sub 打印报表()
'一键打印4张报表,打印源为当前文档前4张表,打印格式:前3张纵向,第四张横向,页边距左右0.5,上下默认,左右剧中,缩放到一页。

If MsgBox("是否一键打印4张表?", vbYesNo + vbDefaultButton1 + vbInformation, "打印提示") = vbNo Then
    Exit Sub
End If

Dim Sht_Out As Worksheet
Dim i As Integer
Dim MyPrtr As String

'选择打印机
If Application.Dialogs(xlDialogPrinterSetup).Show Then
     MyPrtr = Application.ActivePrinter
End If

For i = 1 To 4
    Set Sht_Out = ThisWorkbook.Worksheets(i)
    Application.PrintCommunication = False
    With Sht_Out.PageSetup
        .PrintTitleRows = ""
        .PrintTitleColumns = ""
    End With
    Application.PrintCommunication = True
    ActiveSheet.PageSetup.PrintArea = ""
    Application.PrintCommunication = False
    With Sht_Out.PageSetup
        .LeftHeader = ""
        .CenterHeader = ""
        .RightHeader = ""
        .LeftFooter = ""
        .CenterFooter = ""
        .RightFooter = ""
        .LeftMargin = Application.InchesToPoints(0.196850393700787)
        .RightMargin = Application.InchesToPoints(0.196850393700787)
        .TopMargin = Application.InchesToPoints(0.748031496062992)
        .BottomMargin = Application.InchesToPoints(0.748031496062992)
        .HeaderMargin = Application.InchesToPoints(0.31496062992126)
        .FooterMargin = Application.InchesToPoints(0.31496062992126)
        .PrintHeadings = False
        .PrintGridlines = False
        .PrintComments = xlPrintNoComments
        .PrintQuality = 600
        .CenterHorizontally = True
        .CenterVertically = False
        If i = 4 Then
        .Orientation = xlLandscape
        Else
        .Orientation = xlPortrait
        End If
        .Draft = False
        .PaperSize = xlPaperA4
        .FirstPageNumber = xlAutomatic
        .Order = xlDownThenOver
        .BlackAndWhite = False
        .Zoom = False
        .FitToPagesWide = 1
        .FitToPagesTall = 1
        .PrintErrors = xlPrintErrorsDisplayed
        .OddAndEvenPagesHeaderFooter = False
        .DifferentFirstPageHeaderFooter = False
        .ScaleWithDocHeaderFooter = True
        .AlignMarginsHeaderFooter = True
        .EvenPage.LeftHeader.Text = ""
        .EvenPage.CenterHeader.Text = ""
        .EvenPage.RightHeader.Text = ""
        .EvenPage.LeftFooter.Text = ""
        .EvenPage.CenterFooter.Text = ""
        .EvenPage.RightFooter.Text = ""
        .FirstPage.LeftHeader.Text = ""
        .FirstPage.CenterHeader.Text = ""
        .FirstPage.RightHeader.Text = ""
        .FirstPage.LeftFooter.Text = ""
        .FirstPage.CenterFooter.Text = ""
        .FirstPage.RightFooter.Text = ""
    End With
    Application.PrintCommunication = True
    
    Sht_Out.PrintOut ActivePrinter:=MyPrtr
    
Next i

End Sub