Run VBA macro via C # Interop?

just wondering, can anyone suggest why I might get an error? I am currently trying to execute a macro in a workbook by calling the Application.Run method, which provides interop.

It currently throws the following COM Exception:

{System.Runtime.InteropServices.COMException (0x800A03EC): Cannot run the macro Macro1'. 
The macro may not be available in this workbook or all macros may be disabled.

I put the containing book in a safe place, set all security settings to their minimum values ​​and trust programmatic access to my object model. I am completely out of ideas, and Google has so far failed me!

Has anyone done this, or can you suggest something that I could try?

Many thanks!

+3
source share
5 answers

, , . " : " VBA. VBA, , , , - .

+1

, , : personal.xls! macroname

0

, Ive . , Microsoft

0

Interop, , Excel. :

Excel Addin Interop

0

I encountered the same problem, Macro is stored in the "Module" with the name "MainModule".

I tried

App.Run("Abc.xlsm!CalcSomething");

App.Run("MainModule!CalcSomething");

App.Run("Abc.xlsm.CalcSomething");

App.Run("MainModule.CalcSomething");

App.Run("CalcSomething);

Nothing succeeded.

0
source

All Articles