I have an Excel add-in, and I would like to do the following:
- Check if the workbook has macro.
- Prompt user if he wants to enable the macro.
- If yes, enable the macro for user.
Is there a way to enable a macro in C#?
I have an Excel add-in, and I would like to do the following:
Is there a way to enable a macro in C#?
This article is very helpful for you.
According to the article, I implemented this as a WinForm application so I used
MessageBox
to prompt user if he wants to enable the macro.Before doing this, you have to check "Trust access to the VBA project object model" at [File]->[Options]->[Trust Center] in your "xlsm" workbook.