Automation MS Office: receive notification (event) when running a macro

I am developing an MS Office add-in (Excel, Word, PowerPoint and Outlook) using C # /. NET, which tracks and logs some events when they occur as DocumentOpen, DocumentContentChange..etc However, after several days of searching, I can’t find a way (event) to receive a notification when a macro runs in an Excel workbook, Word Document, etc. .d.

The hard way is to try to catch every possible path that the user can follow in order to run the macro using the mouse API and Keyboard Hooking Win API, which:

  • Using the Macros dialog (using a purely Win API to access the window): OnClick, if it is ActiveWindow, and the Run button has focus, read the value in the TextBox under the label "Macro Name:", but I found this approach very complicated , as there are some cases, for example: the user presses ENTER, and the focus is not on the Run button, or if the DoubleClick user is on an item in the list of macros that run the macro.
  • Pressing the key combination:, and the macro has the associated key combination Ctrl + F8.

  • Click on a shape (basically excel): check to see if that shape is attached to it.

I see that these approaches are very limited.

Do you have the best deals?

+4
1

, , - . , , , , .

0

Source: https://habr.com/ru/post/1542647/


All Articles