发布网友 发布时间:2022-04-21 13:12
共1个回答
热心网友 时间:2023-11-11 01:40
试试下面代码吧
Sub 打印奇偶页()
Dim TotalPg As Integer
TotalPg = ExecuteExcel4Macro("GET.DOCUMENT(50)")
MsgBox "现在开始打印奇数页"
'设置页边距(英寸)(1英寸=2.54厘米)
With ActiveSheet.PageSetup
.LeftMargin = Application.InchesToPoints(2.3622) '左边距6cm
.RightMargin = Application.InchesToPoints(0.748) '右边距1.9cm
End With
For i = 1 To TotalPg Step 2
ActiveSheet.PrintOut From:=i, To:=i
Next
MsgBox "现在开始打印偶数页"
'设置页边距
With ActiveSheet.PageSetup
.LeftMargin = Application.InchesToPoints(0.748) '左边距1.9cm
.RightMargin = Application.InchesToPoints(2.3622) '右边距6cm
End With
For i = 2 To TotalPg Step 2
ActiveSheet.PrintOut From:=i, To:=i
Next
End Sub