Question

Sherihan Anver on Wed, 05 Jun 2013 08:39:49


I want to know if there is a way to call a macro from a VS add-in project. I have created a macro and now want to call its modules from a button click event of my add-in project. If someone knows the solution, please leave a reply.

Sponsored



Replies

Carlos J. Quintero on Wed, 05 Jun 2013 11:15:11


Since macros have associated commands (Macros.*, check the names in Tools, Customize... Keyboard button, "Show commands containing") you can use DTE.ExecuteCommand(commandName).

That said, it is a very bad idea to make an add-in to depend on external macros. It's better to incorporate the code of the macro inside the add-in, or avoid the add-in and create buttons from commands using Tools, Customize... Commands tab , Add Command button.