This document is archived and information here might be outdated.  Recommended version.


Get PageLayout from ArcMap Snippet (ArcObjects .NET 10.4 SDK)
ArcObjects Library Reference

Get PageLayout from ArcMap Snippet

Get PageLayout from ArcMap.

[C#]
///<summary>Get PageLayout from ArcMap</summary>
///  
///<param name="application">An IApplication interface that is the ArcMap application.</param>
///   
///<returns>An IPageLayout interface.</returns>
///   
///<remarks></remarks>
public ESRI.ArcGIS.Carto.IPageLayout GetPageLayoutFromArcMap(ESRI.ArcGIS.Framework.IApplication application)
{
  if(application == null)
  {
    return null;
  }
  ESRI.ArcGIS.ArcMapUI.IMxDocument mxDocument=((ESRI.ArcGIS.ArcMapUI.IMxDocument)(application.Document)); // Explicit Cast
  ESRI.ArcGIS.Carto.IPageLayout pageLayout=mxDocument.PageLayout;

  return pageLayout;

}
[Visual Basic .NET]
'''<summary>Get PageLayout from ArcMap</summary>
'''  
'''<param name="application">An IApplication interface that is the ArcMap application.</param>
'''   
'''<returns>An IPageLayout interface.</returns>
'''   
'''<remarks></remarks>
Public Function GetPageLayoutFromArcMap(ByVal application As ESRI.ArcGIS.Framework.IApplication) As ESRI.ArcGIS.Carto.IPageLayout

  If application Is Nothing Then
    Return Nothing
  End If

  Dim mxDocument As ESRI.ArcGIS.ArcMapUI.IMxDocument=(CType(application.Document, ESRI.ArcGIS.ArcMapUI.IMxDocument)) ' Explicit Cast
  Dim pageLayout As ESRI.ArcGIS.Carto.IPageLayout=mxDocument.PageLayout

  Return pageLayout

End Function

Additional Requirements
  • The code in this document requires the following References added to the Visual Studio project:
  • ESRI.ArcGIS.ArcMapUI
  • ESRI.ArcGIS.Carto
  • ESRI.ArcGIS.Framework
  • ESRI.ArcGIS.System