Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Referencing a com addin from a .net application via ole automation
Hi
I'm developing a c# application integrated with excel via ole automation. I've developed an excel commandbar and handle buttons' click events. So far, so good. I got stuck with accessing my com addin from the .net application. I couldn't find any official documentation, so following a vb example that I found on the web, I'm passing the addin instance: class Connect : Object, Excensibility.IDTExcensibility2 { .... public void OnConnection(object application, Extensibility.ext_ConnectMode connectMode, object addInInst, ref System.Array custom) { addInInst.GetType().InvokeMember("Object", BindingFlags.Public | BindingFlags.SetProperty, null, addInInst, new object [] {this}); } .... } According to the example I should be able to the addin from my application: foreach(Office.ComAddIn comAddin in xlApp.COMAddIns) { if (comAddIn.ProgId.Equals("ComAddin.Connect")) { ComAddin.Connect com = (ComAddin.Connect) comAddIn.GetType().InvokeMember("Object", BindingFlags.Public | BindingFlags.GetProperty, null, comAddIn, null); } } However I get an exception saying that the 'Specified cast is not valid'. Is there some other way to access my com addin? Cheers, Luke |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
UDF's via Automation Addin in Excel 2010? | Excel Worksheet Functions | |||
addIn functions in automation | Excel Programming | |||
May be Automation AddIn loading problem!! | Excel Programming | |||
Automation COM Addin with Excel | Excel Programming | |||
application is not getting closed through automation | Excel Programming |