|
打印的代码
Sub 批量打印()
'定义变量
Dim ws As Worksheet
Dim wsIndex As Integer
Dim wsIndices As Variant
Dim indx As Variant
'需要打印的工作表索引
wsIndices = Array("审批表", "谈判报告", "人员登记表", _
"承诺书", "汇总排序表", "初评", "监督报告")
For Each indx In wsIndices
'选定工作表
Set ws = ThisWorkbook.Sheets(indx)
With ws.PageSetup
'重置设置
.Zoom = False
.FitToPagesTall = False
.FitToPagesWide = False
End With
Select Case indx
Case "审批表"
'将工作表调整为一页
With ws.PageSetup
.FitToPagesTall = 1
.FitToPagesWide = 1
End With
ws.PrintOut
Case "谈判报告"
'打印前3页
ws.PrintOut From:=1, To:=3
Case 人员登记表"
With ws.PageSetup
.Orientation = xlLandscape ' 设置为横向打印
End With
ws.PrintOut
Case "汇总排序表"
With ws.PageSetup
.Orientation = xlLandscape ' 设置为横向打印
End With
ws.PrintOut
Case Else
'其他工作表仅打印第一页
ws.PrintOut From:=1, To:=1
End Select
Next indx
Set ws = Nothing
End Sub
文档打印完成后,打印机程序里面是这样
|
|