How to run Excel macros from VS?

How to run Excel macros from VS2010 (C #)? I am using the Microsoft.Office.Interop.Excel namespace

+6
c # excel
source share
2 answers

Try this article:

http://support.microsoft.com/kb/306683

The relevant part to run the macro is (where oApp is the application instance in your code):

 private void RunMacro(object oApp, object[] oRunArgs) { oApp.GetType().InvokeMember("Run", System.Reflection.BindingFlags.Default | System.Reflection.BindingFlags.InvokeMethod, null, oApp, oRunArgs); } 
+7
source share

In addition to amarsuperstar's answer,

I would like to state that you must be a reliable source to call these macros. And the Excel file itself also needs to be trusted.

+1
source share

All Articles