How to move the selection anchor to a polygon label


This script moves the selection anchor to a polygon's label point. By default, ArcMap places the selection anchor at the center of the selected feature's envelope, which may or may not fall within the selected polygon.

How to use

  1. Select one polygon feature.
  2. Paste the code into VBA and run the macro.
[VBA]
Public Sub PlaceAnchorPointatLabel()
    Dim pEditor As IEditor
    Dim pArea As IArea
    Dim pPolygon As IPolygon
    Dim pID As New UID
    
    'Get a handle to the Editor
    pID = "esriEditor.Editor"
    Set pEditor = Application.FindExtensionByCLSID(pID)
    
    If Not pEditor.SelectionCount = 1 Then Exit Sub
    
    'Get the selected feature and move the Editor's selection anchor
    'To the labelpoint of the polygon
    If TypeOf pEditor.EditSelection.Next.Shape Is Polygon Then
        Set pPolygon = pEditor.EditSelection.Next.Shape
        Set pArea = pPolygon
        pEditor.SelectionAnchor.MoveTo pArea.LabelPoint, pEditor.Display
    End If
    
End Sub






Additional Requirements
  • An Edit Session.