在excel的“页面布局”选项卡下可以设置纸张的方向。
比如设置为横向或纵向。
在vba中可以通过设置PageSetup对象的Orientation属性调整工作表的纸张打印方向。
Sub QQ1722187970()
Excel.Application.ScreenUpdating = False
Excel.Application.Calculation = xlCalculationManual
Dim oWK As Worksheet
For Each oWK In Excel.ThisWorkbook.Worksheets
With oWK.PageSetup
'横向
.Orientation = xlLandscape
'纵向
.Orientation = xlPortrait
End With
Next
Excel.Application.ScreenUpdating = True
Excel.Application.Calculation = xlCalculationAutomatic
End Sub


发表评论