Problem: Annotation is not rotating when the data frame is rotated


Text annotation in ArcMap is not rotating when the Rotate Data Frame Tool is used. This can happen with both Geodatabase annotation and with annotation stored in the map.


Some ArcGIS annotation does not rotate with the data frame. This includes some annotation created in earlier versions of ArcGIS. This means that when the Data Frame Rotate tool is used, the annotation does not rotate along with the data.

Solution or Workaround

In ArcGIS version 8.3 and later, run a VBA code to modify the annotation so it rotates when the data frame is rotated.

The reverse is also possible: to make annotation that rotates with the data frame, remain stationary.

Follow the steps below.

  1. Open a new ArcMap document and add the annotation, if there is Geodatabase annotation present. If there is map annotation present, open the map document that contains the annotation.
  2. Open the Visual Basic Editor, from the Tools menu in ArcMap, and add the following code:


    Option Explicit


    Public Sub SetAnnotationRotateFlag_Geodatabase()
    ' 1. Start Editing
    ' 2. Select Geodatabase annotation features using Edit tool
    ' 3. Change Const value above to either True or False (True = rotate text when dataframe rotates)
    ' 4. Run this code
    ' 5. Stop Editing, Save Edits

    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

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

    Set pEnumFeature = pEditor.EditSelection

    Dim pElement As IElement
    Dim pAnnoF As IAnnotationFeature
    Dim pTextElement As ITextElement
    Dim theAnnoString As String
    Dim stringToReplace As String
    Dim replacementString As String
    Dim pTextSym As ITextSymbol
    Dim pSymRot As ISymbolRotation

    Set pFeature = pEnumFeature.Next
    Do Until pFeature Is Nothing

    Set pAnnoF = pFeature
    Set pElement = pAnnoF.Annotation

    'only work with text elements
    If TypeOf pElement Is ITextElement Then
    Set pTextElement = pElement
    Set pTextSym = pTextElement.Symbol
    Set pSymRot = pTextSym

    pSymRot.RotateWithTransform = ROTATE_WITH_TRANSFORM

    pTextElement.Symbol = pTextSym
    pAnnoF.Annotation = pElement
    Set pFeature = pAnnoF
    End If

    Set pFeature = pEnumFeature.Next

    pEditor.StopOperation "Set Rotate With Transform"

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

    Public Sub RotateWithTransform_Map()
    ' 1. Select Map annotation using the Select Elements tool
    ' 2. Change Const value above to either True or False (True = rotate text when dataframe rotates)
    ' 3. Run this code
    ' 4. Save your .mxd to save changes

    Dim pMxDoc As IMxDocument
    Set pMxDoc = ThisDocument
    Dim pGraphicsContSelect As IGraphicsContainerSelect
    If pMxDoc.ActiveView Is pMxDoc.PageLayout Then
    Set pGraphicsContSelect = pMxDoc.PageLayout
    Set pGraphicsContSelect = pMxDoc.FocusMap
    End If

    Dim pElement As IElement
    Dim Count As Long
    Count = pGraphicsContSelect.ElementSelectionCount - 1
    Dim i As Long

    For i = 0 To Count
    Set pElement = pGraphicsContSelect.SelectedElement(i)
    If TypeOf pElement Is ITextElement Then
    Dim pTextElement As ITextElement
    Dim pTextSymbol As ITextSymbol
    Dim pSymbolRotation As ISymbolRotation
    Set pTextElement = pElement
    Set pSymbolRotation = pTextElement.Symbol
    pSymbolRotation.RotateWithTransform = ROTATE_WITH_TRANSFORM
    pTextElement.Symbol = pSymbolRotation
    End If
    Next i

    End Sub

  3. There are two subroutines, the first works for Geodatabase annotation, and the other works for map document annotation. Find the routine that fits the situation and follow the directions at the top of the subroutine to run it.

Related Information