Word VBA: Setting Page Orientation to Landscape

This Word VBA macro sets the page orientation of an active document to landscape.

Macro Example

Sub SetPageOrientationToLandscape()

  ActiveDocument.PageSetup.Orientation = wdOrientLandscape

End Sub

Description

(Application.)ActiveDocument

  ActiveDocument...

The Application.ActiveDocument property returns an active Document object.

obj-Word-Application-ActiveDocument

The ActiveDocument property is a member of the Word.Global class, so we can omit the Application property.

obj-Word-ActiveDocument

ActiveDocument.PageSetup (Document.PageSetup)

  ActiveDocument.PageSetup...

The ActiveDocument.PageSetup (Document.PageSetup property) returns a PageSetup object that is associated with the active document.

obj-Word-Document-PageSetup

PageSetup.Orientation

  ActiveDocument.PageSetup.Orientation...

The PageSetup.Orientation property returns or sets the orientation of the page.

obj-Word-PageSetup-Orientation

In this macro, I set it to landscape orientation by setting the const: wdOrientLandscape.

Sub SetPageOrientationToLandscape()

  ActiveDocument.PageSetup.Orientation = wdOrientLandscape

End Sub

Properties

http://www.relief.jp/itnote/archives/word-vba-orientation-landscape.php

Apply To

  • Word 2013
  • Word 2010
  • Word 2007