EventHandlers not firing inside ThisDocument class in Word

I have a strange problem.  I have a Word Document project in which I have wired up an event handler called MedicalDocumentNode_ContextEnter for a node called MedicalDocument.  This normally works great.

However, if I access the XML of the word document within my ThisDocument class, by doing the following (as an example):

MessageBox.Show(Application.Selection.get_XML(false));

It seems to cause the environment to go out of sync with the event handling and the event handler above does not get called.

Any input on this strange behaviour



Answer this question

EventHandlers not firing inside ThisDocument class in Word

  • jrwalker2

    Okay, I managed to solve this one quite shortly after posting the thread.  I changed tack a little after searching on Google.  Basically I got to the XML by using the following code:

    this.Content.get_XML(false)

    Don't ask me why it makes a difference, but it does.  Any takers on explaining this


  • EventHandlers not firing inside ThisDocument class in Word