PageSetup 属性 (Excel)PageSetup.Orientation property (Excel)

返回或设置一个**XlPageOrientation** 值, 它代表纵向或横向打印模式。Returns or sets an XlPageOrientation value that represents the portrait or landscape printing mode.

语法Syntax

表达式方向expression.Orientation

_表达式_一个代表**PageSetup** 对象的变量。expression A variable that represents a PageSetup object.

示例Example

本示例将 Sheet1 设置为横向打印。This example sets Sheet1 to be printed in landscape orientation.

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

本示例将当前活动工作表设置为纵向打印。This example sets the currently active sheet to be printed in portrait orientation.

ActiveSheet.PageSetup.Orientation = xlPortrait

此过程将方向切换为相反的选项。This procedure switches the orientation to the opposite option.

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

支持和反馈Support and feedback

有关于 Office VBA 或本文档的疑问或反馈?Have questions or feedback about Office VBA or this documentation? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.