都知道,在Excel里执行打印命令时,是不能实现双面打印的。如果需要在Excel里打印双面,可以借助VBA编写程序来实现。
按
进入VBE,新建一个模块,将下面的程序复制到模块中,执行程序即可打印。
Sub 双面打印()
Dim PageCount As Long, x As Integer, PrintPage As Long
PageCount = Application.ExecuteExcel4Macro("get.document(50)") '获得要打印的页数
'判断要打印的页数是奇数还是偶数
If PageCount Mod 2 = 0 Then
x = 1
Else
x = 0
End If
'每隔两页打一次,从最大页开始打印
For PrintPage = PageCount - x To 1 Step -2
ActiveSheet.PrintOut from:=PringPage, To:=PringPage
ActiveSheet.PrintOut from:=jPage, To:=jPage
Next
If MsgBox("请将纸得新装入打印机,单击【确定】后继续。", vbOKCancel, "双面打印") = vbOK Then
'打印另一面,从小页到大页
If OK = vbOK Then
For PrintPage = 2 To PageCount Step 2
ActiveSheet.PrintOut from:=PrintPage, To:=PrintPage
Next
End If
End Sub
阅读(4321) | 评论(0) | 转发(0) |