HOW TO
Note: This article pertains to ArcGIS versions 8.x. Later versions of ArcGIS may contain different functionality, as well as different names and locations for menus, commands and geoprocessing tools.
You can automatically place labels representing bordering maps' page numbers. This example assumes page numbers increase by 1 to the north and by 100 to the east. So the page number of a map to the northwest of map 1245 would be 1146. This example also assumes the map page is 8.5 x 11. Edit the code to work with other page sizes.
Note: 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: For more information on creating a UIControl, see the ArcGIS Desktop Help topic: 'Creating custom commands with VBA and UI Controls'
Private Sub UIButtonControl1_Click() Dim pMxDoc As IMxDocument Dim pActiveView As IActiveView Dim pGraphicsContainer As IGraphicsContainer Set pMxDoc = Application.Document If Not pMxDoc.ActiveView Is pMxDoc.PageLayout Then MsgBox "Switch to Layout view in order to use this tool" Exit Sub End If Set pActiveView = pMxDoc.PageLayout Set pGraphicsContainer = pMxDoc.PageLayout Dim CurrentMap As Double Dim NorthMap, NorthEastMap, NorthWestMap, SouthMap, SouthEastMap, SouthWestMap, WestMap, EastMap CurrentPageNumber = InputBox("Enter Current page Number") If IsNumeric(CurrentPageNumber) Then Else MsgBox "Invalid page number entry. Try again." Exit Sub End If 'Variable List = A list (Bordering Map, X location of text, Y location of text, Rotation Angle) NorthMap = Array(CurrentPageNumber + 1, 4.25, 10.1, 0) EastMap = Array(CurrentPageNumber + 100, 7.75, 5.5, 90) WestMap = Array(CurrentPageNumber - 100, 0.75, 5.5, 270) SouthMap = Array(CurrentPageNumber - 1, 4.25, 0.75, 0) NorthEastMap = Array(CurrentPageNumber + 101, 7.9, 10.3, 45) NorthWestMap = Array(CurrentPageNumber - 99, 0.6, 10.35, 315) SouthWestMap = Array(CurrentPageNumber - 99, 0.65, 0.6, 45) SouthEastMap = Array(CurrentPageNumber + 99, 7.85, 0.6, -45) Dim MapList As Variant MapList = Array(NorthMap, NorthEastMap, NorthWestMap, SouthMap, SouthEastMap, SouthWestMap, EastMap, WestMap) Dim pTextElement As ITextElement Dim pElement As IElement Dim pGeometry As IGeometry Dim pPoint As IPoint Dim pTrans2D As ITransform2D For Each Map In MapList Set pTextElement = New TextElement Set pTrans2D = pTextElement Set pPoint = New Point Set pGeometry = pPoint Set pElement = pTextElement pTextElement.Text = "MAP # " & Map(0) pPoint.x = Map(1) pPoint.y = Map(2) pElement.Geometry = pPoint pTrans2D.Rotate pPoint, Map(3) * 22 / 1260 pGraphicsContainer.AddElement pElement, 0 Next pMxDoc.ActiveView.PartialRefresh esriViewGraphics, Nothing, Nothing End Sub
Article ID:000005045
Get help from ArcGIS experts
Download the Esri Support App