I have a Macro which fetches some data into the excel file from the Microsoft office outlook (inbox or any other folder). To get the excel file I have to manually run the Macro in the outlook. Is there any way to call the Macro from the C#. I tried to search on Google but couldn’t find anything specific. This is an immediate requirement. Any help with this!!
1 Answer
Look here This should get you started.
its something along the lines of:
myApp = (Microsoft.Office.Interop.Outlook.ApplicationClass)(Marshal.GetActiveObject("Outlook.Application")); then have a RunMacro(object theApp, object[] theArgs) method, then you will need to invoke a run on the app and the data inside this method.
2 Comments
waris kantroo
Thank you. Would you please be kind enough and tell me how i have to specify the Macro path in C#. I am clueless.
gavlaaaaaaaa
theApp.GetType().InvokeMember("Run", System.Reflection.BindingFlags.InvokeMethod, null, theApp, theArgs); Im guessing something along these lines. Not tested though. Then run with: RunMacro(myApp, new Object[] { "macroName" });