Skip to content

Latest commit

 

History

History
58 lines (38 loc) · 1.2 KB

Excel.PageSetup.Orientation.md

File metadata and controls

58 lines (38 loc) · 1.2 KB
title keywords f1_keywords api_name ms.assetid ms.date ms.localizationpriority
PageSetup.Orientation property (Excel)
vbaxl10.chm473090
vbaxl10.chm473090
Excel.PageSetup.Orientation
9e41d5c8-e887-3212-c298-c2921137ec9c
05/03/2019
medium

PageSetup.Orientation property (Excel)

Returns or sets an XlPageOrientation value that represents the portrait or landscape printing mode.

Syntax

expression.Orientation

expression A variable that represents a PageSetup object.

Example

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

[!includeSupport and feedback]