In visual studio I am creating an addin, in the addin_startup I am setting an Outlook application to
app = (Microsoft.Office.Interop.Outlook.ApplicationClass)(Marshal.GetActiveObject("Outlook.Application"));
then I am calling a runMacro function which I got from msdn
private void RunMacro(object oApp, object[] oRunArgs)
{
try
{
oApp.GetType().InvokeMember("Run", System.Reflection.BindingFlags.InvokeMethod, null, oApp, oRunArgs);
}
catch (Exception e)
{
MessageBox.Show(e.GetType().ToString());
}
}
I pass this function, my Outlook app object and the name of the macro to run in an array, as so...
RunMacro(app, new Object[] { "showFormDisplay" });
I get the following exception
Unknown name. (Exception from HRESULT: 0x80020006 (DISP_E_UNKNOWNNAME))