Zoom out on the dataframe using ArcObjects.

Last Published: April 25, 2020


This article contains a code sample that shows how to zoom out on the dataframe using VBA.


  1. Start ArcMap.
  2. Open the Visual Basic Editor.

    In ArcMap, select Tools > Macros > Visual Basic Editor.

  3. In the Project Explorer window, expand Project.mxt and select ArcMap Objects > ThisDocument, then right-click and select View Code.
    [O-Image] Visual Basic Project  Explorer

    Code in the Project's ThisDocument code module will only run in the current map document. If you want to store the code in all your map documents open the Normal.mxt ThisDocument code module instead.

  4. Copy the following code into the code module.

    Sub zoomout()

    Dim pMxDoc As IMxDocument
    Dim pActiveView As IActiveView
    Dim pExtentEnv As IEnvelope

    Set pMxDoc = ThisDocument
    Set pActiveView = pMxDoc.ActiveView
    Set pExtentEnv = New Envelope
    Set pExtentEnv = pActiveView.Extent
    'the following line will double the extent
    pExtentEnv.Expand 2, 2, True

    pActiveView.Extent = pExtentEnv

    End Sub

  5. Close the Visual Basic Editor.
  6. Run the code.

    A. Click Tools > Macros > Macros to display the Macros dialog box.
    B. Select a macro and click Run.

Article ID:000005948

  • ArcMap 8 x
  • ArcMap 9 x

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options

Discover more on this topic