HOW TO
This article shows how to create a new graticule and set its properties in ArcMap 8.x.
Note: These instructions pertain to ArcGIS 8.x. Support for Visual Basic for Applications (VBA) for ArcMap and ArcCatalog ended with the ArcGIS 10.2.2 release, and Esri has not included VBA compatibility setups since version 10.5. See: ArcGIS Desktop and VBA Moving Forward
Note: Code in ThisDocument module only runs in the current map document. To store the code in all your map documents, open the Normal.mxt ThisDocument code module.
Sub AddGraticule() Dim pMxDoc As IMxDocument Dim pGC As IGraphicsContainer Dim pElem As IElement Dim pMapFrame As IMapFrame Dim pMapGrids As IMapGrids Dim pMapGrid As IMapGrid Dim pActView As IActiveView ' Find the map frame Set pMxDoc = ThisDocument Set pGC = pMxDoc.PageLayout pGC.Reset Set pElem = pGC.Next Do While (Not pElem Is Nothing) If (TypeOf pElem Is IMapFrame) Then Set pMapFrame = pElem Exit Do End If Set pElem = pGC.Next Loop If (pMapFrame Is Nothing) Then MsgBox "Can't find a MapFrame" Exit Sub End If ' Create graticule object Set pMapGrid = New Graticule ' Set default parameters based on the map ' NOTE: If X and Y grid intervals are not set to non-zero by this ' or another means (e.g., via IMeasuredGrid), the graticule drawing ' procedure will stop responding pMapGrid.SetDefaults pMapFrame ' The name will be shown in the Grids property page pMapGrid.Name = "My Graticule" ' Add graticule to the grid collection Set pMapGrids = pMapFrame pMapGrids.AddMapGrid pMapGrid ' Refresh the view Set pActView = pMxDoc.ActiveView pActView.Refresh End Sub
Get help from ArcGIS experts
Download the Esri Support App