Rotate text programmatically


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.

Instructions provided describe how to rotate text programmatically. When setting the Angle property on an ITextSymbol object, the text does not move because the Angle property is not implemented. This is a known issue at ArcGIS 8.1 and 8.2.

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


The workaround is to use the interface ITransform2D.

  1. Start ArcMap.
  2. Create a new UIButtonControl: How To: Create a new UIButtonControl​
 For more information on creating a UIControl, see the ArcGIS Desktop Help topic: 'Creating custom commands with VBA and UI Controls'
  1. Right-click the UIButtonControl and select View Source.
  2. Copy this code into the UIButtonControl's click event.
Dim pMxDoc As IMxDocument 
Set pMxDoc = ThisDocument 
Dim pLayout As IPageLayout 
Set pLayout = pMxDoc.PageLayout 

Dim pGC As IGraphicsContainer 
Set pGC = pLayout 

Dim pFont As IFontDisp 
Set pFont = New StdFont 
pFont.Size = 15 
pFont.Name = "Arial Black" 
pFont.Bold = True 
Dim pTextElem As ITextElement 
Set pTextElem = New TextElement 

Dim pTextSym As ITextSymbol 
Set pTextSym = New TextSymbol 

'''This line is ignored at ArcGIS 8.1 and 8.2 
pTextSym.Angle = 45 
pTextSym.Font = pFont 
pTextSym.Size = pFont.Size 

pTextElem.Symbol = pTextSym 
pTextElem.Text = "TestText" 

Dim pPoint As IPoint 
Set pPoint = New Point 
pPoint.X = 4 
pPoint.Y = 5.5 

Dim pElem As IElement 
Set pElem = pTextElem 
pElem.Geometry = pPoint 

pGC.AddElement pElem, 0 
'''''This is the workaround using angle... 
Dim pTwoD As ITransform2D 
Set pTwoD = pElem 
pTwoD.Rotate pPoint, 0 

pMxDoc.ActiveView.PartialRefresh esriViewGraphics, Nothing, Nothing
  1. Click Layout View from the View menu.
  2. Click the new button to run the code. A new text element is added near the center of the layout. The element is rotated from the horizontal.

Article ID:000004395

  • ArcMap 8 x

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options

Discover more on this topic