HOW TO
Instructions provided change the properties of a text element using an ArcObjects sample.
Note:
Code in the Project's ThisDocument code module will only run in the current map document. To store the code in all map documents open the Normal.mxt ThisDocument code module.
Code:
Sub ChangeFont_of_TextElements()
Dim pMxDoc As IMxDocument
Dim pLayout As IPageLayout2
Dim pGraphicsContainer As IGraphicsContainer
Dim pElement As IElement
Dim pTextElement As ITextElement
Set pMxDoc = ThisDocument
Set pLayout = pMxDoc.PageLayout
Set pGraphicsContainer = pLayout
'create symbol
Dim pFontDisp As IFontDisp
Dim pRGB As IRgbColor
Dim pSym As ITextSymbol
Dim pFTextSym As IFormattedTextSymbol
Set pFontDisp = New StdFont
pFontDisp.Bold = True
pFontDisp.Italic = True
pFontDisp.Name = "Georgia"
pFontDisp.Size = 24
Set pRGB = New RgbColor
pRGB.Red = 255
pRGB.Blue = 200
pRGB.Green = 200
Set pSym = New TextSymbol
Set pFTextSym = pSym
pSym.Font = pFontDisp
pSym.Color = pRGB
pGraphicsContainer.Reset
Set pElement = pGraphicsContainer.Next
While Not pElement Is Nothing
If TypeOf pElement Is ITextElement Then
Set pTextElement = pElement
pTextElement.Symbol = pSym
End If
Set pElement = pGraphicsContainer.Next
Wend
pMxDoc.ActiveView.Refresh
End Sub
Article ID:000006701
Get help from ArcGIS experts
Download the Esri Support App