Geodatabase annotation rotates when the projection of the ArcMap Data Frame changes

Last Published: April 25, 2020


Geodatabase annotation displayed in the ArcMap window rotates, so it is no longer horizontal to the page when the projection of the ArcMap Data Frame is changed.

The contents of this article do not apply to splined annotation or annotation created to follow the angle of a line segment.


When geodatabase annotation is created in a specific coordinate system, the annotation is horizontal to the page. When the projection of the ArcMap Data Frame is changed to a new Coordinate System with a different Central Meridian, the annotation rotates either clockwise or counterclockwise toward the new Central Meridian.

Solution or Workaround

The script below converts annotation geometry from line to point. With point geometry, the annotation no longer rotates in the ArcMap Data Frame, when the Coordinate System of the Data Frame is changed to include a different Central Meridian value.

Below are the steps for installing and running this script in ArcMap:

  1. Open ArcMap with a new, empty map, and add the annotation feature class to the map.
  2. Go to Tools > Macros > Visual Basic Editor.
  3. In the Visual Basic Editor, in the left pane under Project - Project, open Normal(Normal.mxt) > ArcMap Objects > ThisDocument.
  4. Click Insert > File, navigate to the directory where the file AnnoLine2Point.txt has been saved and double-click on the file to add to the page.
  5. Leaving the Visual Basic Editor window open, return to ArcMap, and start an edit session. The annotation feature class is the Target layer.
  6. Right-click on the name of the annotation feature class in the Table of Contents > Selection > Select All.
  7. Return to the Visual Basic Editor, and click Run > Run Macro, select the Macro 'AnnoLine2Point', and click Run.
    The script below must be installed in a saved MXD file in order to run correctly.

  8. The annotation feature class is converted from line to point geometry, with the point at the Bottom-Center position in relation to the text string. When the projection of the ArcMap Data Frame is changed to a coordinate system with a different Central Meridian value, the annotation no longer rotates and the text strings remain horizontal to the page.
  9. Copy the code below into NotePad, and save the file with the name AnnoLine2Point.txt. The line 'Option Explicit' may be removed, if necessary.

    Option Explicit

    ' Author ESRI BeLux - nov 2004

    Public Sub AnnoLineToPoint()
    ' Condition:
    ' - Start Edit session
    ' - Annotation selected (with text different from null string)
    ' -----------------------------------------------------------
    Dim pEditor As IEditor
    Dim pID As New UID
    Dim pEnumFeature As IEnumFeature
    Dim pFeature As IFeature
    Dim Count As Long
    Dim pActiveView As IActiveView

    Dim number_feature As Integer 'Nombre de features modifiés
    number_feature = 0

    pID = "esriEditor.Editor"
    Set pEditor = Application.FindExtensionByCLSID(pID)

    Set pEnumFeature = pEditor.EditSelection

    Set pFeature = pEnumFeature.Next

    Do Until pFeature Is Nothing
    Dim pElement As IElement
    Dim pAnnoF As IAnnotationFeature
    Set pAnnoF = pFeature
    Set pElement = pAnnoF.Annotation

    If TypeOf pElement Is ITextElement Then
    If TypeOf pElement.Geometry Is IPolyline Then
    Dim pGeometry As IGeometry
    Dim pPointColl As IPointCollection
    Set pGeometry = pFeature.Shape
    Set pPointColl = pGeometry

    Dim pPointColl2 As IPoint
    Set pPointColl2 = New Point
    'Place the point of the point on the middle of the line
    'The text is place in a polygone.
    Dim newx As Double, newy As Double
    newx = ((pPointColl.Point(0).X + pPointColl.Point(3).X) / 2)
    newy = ((pPointColl.Point(0).Y + pPointColl.Point(3).Y) / 2)

    pPointColl2.PutCoords newx, newy
    Set pGeometry = pPointColl2
    pElement.Geometry = pGeometry

    Dim pTextElement As ITextElement
    Set pTextElement = pElement

    Dim pSimpTextSymbol As ISimpleTextSymbol

    'we need to reset the offset because the feature shape doesn't
    'represent it. Otherwise, the text will move if it has offsets
    Set pSimpTextSymbol = pTextElement.Symbol
    pSimpTextSymbol.Angle = 0 ' Force the texte to be horizontal

    pTextElement.Symbol = pSimpTextSymbol
    Set pElement = pTextElement

    pAnnoF.Annotation = pElement
    Set pFeature = pAnnoF
    number_feature = number_feature + 1
    'do nothing for lines: we are working with points here

    End If
    End If

    Set pFeature = pEnumFeature.Next

    pEditor.StopOperation "Convert Line to point annotations for " & number_feature & " features."

    pEditor.Display.Invalidate Nothing, True, esriAllScreenCaches
    End Sub

Article ID:000009577

  • ArcMap 9 x

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options

Discover more on this topic