Change the Paper Orientation


This sample shows you how to change the layout and paper orientation from Potrait to Landscape.

How to use:
  1. Open a new map document in ArcMap and add data. Switch to layout view.
  2. Open the Visual Basic Editor and paste this sample's code into a module.
  3. Run this procedure.
  4. Notice that the page orientation has changed to Landscape. Go to File > Print Preview and notice that the paper orientation has changed as well.
Public Sub ChangePaperOrientation()

    Dim pMxApp As IMxApplication
    Dim pMxDoc As IMxDocument
    Dim pPageLayout As IPageLayout
    Set pMxApp = Application
    Set pMxDoc = ThisDocument
    Set pPageLayout = pMxDoc.PageLayout
    'Change Page and Paper layout
    Dim pPrinter As IPrinter
    Dim pClone As IClone
    Set pClone = pMxApp.Printer
    Set pPrinter = pClone.Clone
    pPrinter.Paper.Orientation = 2
    Set pMxApp.Printer = pPrinter = 2
    'Inform of printer change
    Dim pActiveView As IActiveView
    Set pActiveView = pPageLayout
    pActiveView.PrinterChanged pPrinter

End Sub