English

How To: Set default map units in ArcMap

Summary

In VBA, default map units are set in the MxDocument object's NewDocument event using the MapUnits property of the IMap interface.

Procedure

  1. Start ArcMap.
  2. Open the Visual Basic Editor.
     
    In ArcMap, select Tools > Macros > Visual Basic Editor.
  3. In the Visual Basic Project Explorer, select Normal > ArcMap Objects and double-click ThisDocument to open the code window.
    [O-Image] Visual Basic Project Explorer
  4. In the Normal.mxt ThisDocument (Code) window, select MxDocument as the object and NewDocument as the event.
    [O-Image] Select New Document from This Document Code Window
  5. Add code to the MxDocument_NewDocument function to set the default map units to feet.
    Code:
    Dim pMxDoc as IMxDocument
    Set pMxDoc = ThisDocument
    	
    Dim pMap as IMap
    Set pMap = pMxDoc.FocusMap
    	
    pMap.MapUnits = esriFeet 
    Note:
    The default units can be set to any of ESRI's measurement units. For a complete list, see the ArcObjects Developers Help under esriUnits Constants. 
  6. Close the Visual Basic Editor.
  7. Back in the ArcMap window, double-click the dataframe to open the Dataframe Properties dialog box. Select the General tab. Note the map units.
  8. Close the dialog box and click the New Map button.
  9. Again, double-click the dataframe to open the Dataframe Properties dialog box. Select the General tab. Notice that the map units are now set to feet. Every time a new document is created, the map units are set to feet.
    Note:
    To remove this customization, either remove the code under the NewDocument event, or delete the normal.mxt.

Related Information