Get the Map's Selection from the Editor

Created:1/23/1999
Description:

If your edit tool or task needs the map's currently selected features, the easiest way to get these is to use IEditor::EditSelection.

How to use:
  1. Paste the code into your VBA Application.
  2. Select some features and run the subroutine.
Public Sub EditSelection()
  Dim pApp As IApplication
  Dim pEditor As IEditor
  Dim pEnumFeat As IEnumFeature
  Dim pFeature As IFeature
  Dim Count As Integer
  Dim pID As New UID
  'Get a handle to the Editor extension
  pID = "esriCore.Editor"
  Set pApp = Application
  Set pEditor = pApp.FindExtensionByCLSID(pID)
  'Get the selection
  Set pEnumFeat = pEditor.EditSelection
  pEnumFeat.Reset
  'Loop through the selection and perform some action
  For Count = 0 To pEditor.SelectionCount - 1
    Set pFeature = pEnumFeat.Next
    'In this example return the GeometryType
    MsgBox pFeature.Shape.GeometryType
  Next Count
End Sub