Automatically synchronize display units to match map units


When you change from one projected coordinate system to another, the display units automatically change to match the map units. However, when you change from a projected coordinate system to a geographic coordinate system, the display units remain in their previous linear units. The following sample script synchronizes the map units and display units whenever you change the data frame's coordinate system.


  1. Start ArcMap.
  2. Click Tools > Macros > Visual Basic Editor.
  3. Double-click Normal (Normal.mxt) > ArcMap Objects > This document in the VBA Project window.
  4. Copy the following code into the new window.

    Private WithEvents MapActiveViewEvents As Map

    Private Function MxDocument_NewDocument() As Boolean
    End Function

    Private Function MxDocument_OpenDocument() As Boolean
    End Function

    Private Sub EventListener()
    Dim pMxDoc As IMxDocument
    Set pMxDoc = ThisDocument
    Set MapActiveViewEvents = pMxDoc.FocusMap
    End Sub

    Private Sub MapActiveViewEvents_SpatialReferenceChanged()
    Dim pMxDoc As IMxDocument
    Set pMxDoc = ThisDocument

    Dim pMap As IMap
    Set pMap = pMxDoc.FocusMap

    '-- Set display units to be the same as map units
    pMap.DistanceUnits = pMap.MapUnits
    End Sub

  5. Click File > Save normal.mxt.
  6. Exit the Visual Basics Editor.

    The above code has been associated with the normal template and responds to the SpatialReferenceChanged event. It will be initialized the next time you start a new ArcMap document or load a pre-existing document.

Article ID:000004333

  • 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