S
samdesilva
Hi,
I am using C# to use Excel COM object to add and set up an add-in.
Here, I am using Late Binding concept. Following code allows me to just
open Excel from my program (just to prove it works).
object ExelAppObject;
ExcelAppType = Type.GetTypeFromProgID("Excel.Application");
ExelAppObject = Activator.CreateInstance(ExcelAppType);
objArray = new object[] {true};
retObj = ExcelAppType.InvokeMember("Visible",
BindingFlags.SetProperty,
null,
ExelAppObject ,
objArray);
Now, I want to setup the addin. So get the AddIns object collection
with following:
object addIns = ExcelAppType.InvokeMember("AddIns",
BindingFlags.GetProperty,
null,
ExelAppObject,
null);
At this point, I get the COM object returns to my code and now I try to
add the Add-In.
objArray = new object[] {xllPath};
object addIn = addIns.GetType().InvokeMember("Add",
BindingFlags.InvokeMethod,
null,
addIns,
objArray);
Where xllPath is the file name with the path. This throws an error
saying that remote object got an exception.
Anybody has an idea how to do this? Anyway, the Early Binding is not a
solution due to the version problem.
Many thanks
SAM
I am using C# to use Excel COM object to add and set up an add-in.
Here, I am using Late Binding concept. Following code allows me to just
open Excel from my program (just to prove it works).
object ExelAppObject;
ExcelAppType = Type.GetTypeFromProgID("Excel.Application");
ExelAppObject = Activator.CreateInstance(ExcelAppType);
objArray = new object[] {true};
retObj = ExcelAppType.InvokeMember("Visible",
BindingFlags.SetProperty,
null,
ExelAppObject ,
objArray);
Now, I want to setup the addin. So get the AddIns object collection
with following:
object addIns = ExcelAppType.InvokeMember("AddIns",
BindingFlags.GetProperty,
null,
ExelAppObject,
null);
At this point, I get the COM object returns to my code and now I try to
add the Add-In.
objArray = new object[] {xllPath};
object addIn = addIns.GetType().InvokeMember("Add",
BindingFlags.InvokeMethod,
null,
addIns,
objArray);
Where xllPath is the file name with the path. This throws an error
saying that remote object got an exception.
Anybody has an idea how to do this? Anyway, the Early Binding is not a
solution due to the version problem.
Many thanks
SAM