This is the code I am using. I have tried both early and late binding.
I have also included the exceptions below.
early binding:
code:
_excelApplication.MacroOptions("Report_Alloc", "custom description",
Missing.Value,
Missing.Value, Missing.Value, Missing.Value, "Report.Report",
Missing.Value, Missing.Value, Missing.Value);
Exception Message: "Exception from HRESULT: 0x800A03EC."
StackTrace " at
Microsoft.Office.Interop.Excel._Application.MacroO ptions(Object Macro,
Object Description, Object HasMenu, Object MenuText, Object
HasShortcutKey, Object ShortcutKey, Object Category, Object StatusBar,
Object HelpContextID, Object HelpFile)\r\n at .......
late binding:
code:
object[] parameters = new object[10];
parameters[0] = "Report_Alloc";
parameters[1] = "Some sample description...";
parameters[2] = Missing.Value;
parameters[3] = Missing.Value;
parameters[4] = Missing.Value;
parameters[5] = Missing.Value;
parameters[6] = "Report.Report";
parameters[7] = Missing.Value;
parameters[8] = Missing.Value;
parameters[9] = Missing.Value;
_excelApplication.GetType().InvokeMember("MacroOpt ions",
BindingFlags.InvokeMethod | BindingFlags.Public |
BindingFlags.Instance, null, _excelApplication, parameters, new
System.Globalization.CultureInfo("en-US"));
Exception Message: "Exception has been thrown by the target of an
invocation."
StackTrace " at System.RuntimeType.InvokeDispMethod(String name,
BindingFlags invokeAttr, Object target, Object[] args, Boolean[]
byrefModifiers, Int32 culture, String[] namedParameters)\r\n at
System.RuntimeType.InvokeMember(String name, BindingFlags invokeAttr,
Binder binder, Object target, Object[] args, ParameterModifier[]
modifiers, CultureInfo culture, String[] namedParameters)\r\n at
.......
Inner Exception Message: "MacroOptions method of Application class
failed"
Jim