This sample shows you how to change the layout and paper orientation from Portrait to Landscape.
How to use
- Open a new map document in ArcMap and add data. Switch to layout view.
- Open the Visual Basic Editor and paste this sample's code into a module.
- Run this procedure.
- 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
pPageLayout.page.Orientation = 2
'Inform of printer change
Dim pActiveView As IActiveView
Set pActiveView = pPageLayout
pActiveView.PrinterChanged pPrinter
End Sub