Sub 账单信封 两台打印机同时输出()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
t = Timer
Dim wb As Workbook
Set wb = ThisWorkbook
With ActiveSheet
x = .[z11]: y = .[z14]
If Not IsNumeric(x) Or Not IsNumeric(y) Then GoTo 100
If x > y Then GoTo 100
' ✅ 总体打印确认
If MsgBox("是否确认开始打印编号从 " & x & " 到 " & y & " 的账单和信封?", vbYesNo + vbQuestion, "确认打印") = vbNo Then
GoTo 100
End If
For i = x To y
.[y1] = i
' ------- 打印账单 -------
.PageSetup.PrintArea = "R3:W17"
With .PageSetup
.LeftMargin = Application.CentimetersToPoints(8.2)
.RightMargin = Application.CentimetersToPoints(0)
.TopMargin = Application.CentimetersToPoints(1.5)
.BottomMargin = Application.CentimetersToPoints(1.5)
.HeaderMargin = Application.CentimetersToPoints(0.8)
.FooterMargin = Application.CentimetersToPoints(0.8)
End With
Application.ActivePrinter = "OKI KS4132(PCL6) 在 Ne00:"
.PrintOut
' ------- 打印信封 -------
.PageSetup.PrintArea = "R23:Z30"
With .PageSetup
.LeftMargin = Application.CentimetersToPoints(0)
.RightMargin = Application.CentimetersToPoints(0)
.TopMargin = Application.CentimetersToPoints(0)
.BottomMargin = Application.CentimetersToPoints(0)
.HeaderMargin = Application.CentimetersToPoints(0)
.FooterMargin = Application.CentimetersToPoints(0)
End With
Application.ActivePrinter = "OKI B432(PCL6) 在 Ne01:"
.PrintOut
Next
End With
100:
Application.ScreenUpdating = True
Application.DisplayAlerts = True
MsgBox "共耗时:" & Format(Timer - t, "0.0000") & " 秒!!!", 64
End Sub