title | keywords | f1_keywords | api_name | ms.assetid | ms.date | ms.localizationpriority | ||
---|---|---|---|---|---|---|---|---|
PageSetup.Orientation property (Excel) |
vbaxl10.chm473090 |
|
|
9e41d5c8-e887-3212-c298-c2921137ec9c |
05/03/2019 |
medium |
Returns or sets an XlPageOrientation value that represents the portrait or landscape printing mode.
expression.Orientation
expression A variable that represents a PageSetup object.
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]