Excel) (PageSetup.Orientation 属性

返回或设置表示纵向或横向打印模式的 XlPageOrientation 值。

语法

表达式。方向

表达式 表示 PageSetup 对象的变量。

示例

本示例将 Sheet1 设置为横向打印。

Worksheets("Sheet1").PageSetup.Orientation = xlLandscape

此示例设置当前活动纸张以纵向打印。

ActiveSheet.PageSetup.Orientation = xlPortrait

此过程将方向切换到相反选项。

Sub SwitchOrientation()
    Dim ps As PageSetup
    Set ps = ActiveSheet.PageSetup

    If ps.Orientation = xlLandscape Then
        ps.Orientation = xlPortrait
    Else
        ps.Orientation = xlLandscape
    End If
End Sub

支持和反馈

有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。