请用宏代码回答:Excel工作簿下所有工作表如何批量设置奇偶页都不同的页边距来批量打印?

发布网友 发布时间: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

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com