Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In my VBA application I have a listener set up that listens for OnSketchFinished, when the polygon is created a message box appears and then a userform.

My problem is that the listener will work 90% of the time, not 100%.

Here are the snippets of code in ThisDocument:

Private WithEvents EditEvents As Editor
Private m_pEditor As IEditor
Public Sub SetEvents()    
    ' This is the listener for the Editor
    Dim pID As New UID
    pID = "esriEditor.Editor"
    Set m_pEditor = Application.FindExtensionByCLSID(pID)
    Set EditEvents = m_pEditor
End Sub

Private Function MxDocument_OpenDocument() As Boolean
    Call SetEvents
End Function

Private Sub EditEvents_OnSketchFinished()
    Call frmCityDev.EditEvents               
End Sub

In my form I have code for EditEvents which brings up a msgbox to notify that a new polygon has been created.

Am I missing something to make sure that the listener will always work?

share|improve this question
Your code looks sound. How are you finishing the sketch? F2 or right click and finish sketch? Finishing a part is not the same as finishing the sketch. – Hornbydd Jan 5 '12 at 16:34
I'm double clicking when I finish the polygon, but I've hit F2 aswell and I get the same thing. Funny thing was yesterday I had no problems, today I have just tried it and the listener isnt working. – MapMan Jan 6 '12 at 9:53

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.