none
Running order of macro VS Add-in event handler RRS feed

  • Question

  • Hi 

    We have a VSTO add-in implemented in C# which handles the DocumentOpen and NewDocument events. If I open a Word document that contains a macro which is automatically executed by Word. which is run first: The handlers of the DocumentOpen or the macro? Does anyone have a reference to any documentation on this?

    Thanks

    Tuesday, August 30, 2016 2:43 PM

Answers

  • >>>which is run first: The handlers of the DocumentOpen or the macro? Does anyone have a reference to any documentation on this?

    According to your description, I am not able to find any reference and documentation about this, so I have created a sample to check DocumentOpen or AutoOpen macro which is run first, at last I get this order: first AutoOpen Macro then DocumentOpen event handler.

    Thanks for your understanding.
    • Proposed as answer by David_JunFeng Thursday, September 8, 2016 1:21 AM
    • Marked as answer by David_JunFeng Thursday, September 8, 2016 1:21 AM
    Wednesday, August 31, 2016 7:12 AM

All replies

  • >>>which is run first: The handlers of the DocumentOpen or the macro? Does anyone have a reference to any documentation on this?

    According to your description, I am not able to find any reference and documentation about this, so I have created a sample to check DocumentOpen or AutoOpen macro which is run first, at last I get this order: first AutoOpen Macro then DocumentOpen event handler.

    Thanks for your understanding.
    • Proposed as answer by David_JunFeng Thursday, September 8, 2016 1:21 AM
    • Marked as answer by David_JunFeng Thursday, September 8, 2016 1:21 AM
    Wednesday, August 31, 2016 7:12 AM
  • Thanks for the attempt. My experience of it also shows this, however it is not a proof. But I have tested on many versions of Windows and Office and they all have shown what you show
    Wednesday, August 31, 2016 9:37 AM
  • Hi jeeji,

    Thanks for your sharing your experience with us, that will help other community when they meet same issue. In addition as far as we know that AutoOpen macro is stored in the Normal.dotm template, and Normal.dotm template opens whenever you start Microsoft Office Word. So the AutoOpen macro is started first.

    Thanks for your understanding.
    Thursday, September 1, 2016 6:47 AM