HOW TO
Note: This article pertains to ArcGIS versions 9.x only. Later versions of ArcGIS may contain different functionality, as well as different names and locations for menus, commands and geoprocessing tools.
Instructions provided describe how to set a reference scale for text elements on a map with ArcObjects.
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'
Sub TextElemRefScale()
Dim pDoc As IMxDocument
Dim pContainer As IGraphicsContainer
Dim pElement As IElement
Dim pTextElement As ITextElement
Dim pActiveView As IActiveView
Set pDoc = ThisDocument
Set pActiveView = pDoc.ActiveView
Set pContainer = pActiveView
'Loop through the graphics container
'and find text element
pContainer.Reset
Set pElement = pContainer.Next
While Not pElement Is Nothing
'Get the specific text element
If TypeOf pElement Is ITextElement Then
Set pTextElement = pElement
If pTextElement.Text = "oregon" Then 'specify the text of your text element
Dim pElemProp As IElementProperties3
Set pElemProp = pTextElement
pElemProp.ReferenceScale = 15000000 'change this to the desired reference scale
End If
End If
Set pElement = pContainer.Next
Wend
'refresh only the graphics, which includes text elements
pDoc.ActiveView.PartialRefresh esriViewGraphics, Nothing, Nothing
End Sub
Article ID: 000009079
Get help from ArcGIS experts
Start chatting now