I need to call a method from a third-party .Net assembly. The object I want is public and marked with the ComVisible attribute. The method I want is public, but takes an IRibbonControl . So:
[ComVisible(true)]
public class CustomUI : IRibbonExtensibility
..
..
public void SaveAs(IRibbonControl control);
Is this possible, through CreateObject in VBA for example? I would need to create an IRibbonControl in VBA, right?
I know this doesn’t directly answer your question, but if you setup your Interface with DispIds and regasm it correctly, you “should” be able to use it in VBA. I usually test my COM Exposed objects using VBScript tests on machines.
Handling VB.NET events in VB6 code
Obviously that is VB.NET code, but the attributes etc are just a slightly different format for C#. (Let me know if you need more help on that part)
Can you see the object register correctly in the Registry (either search for references to the dll or look for it’s class name).
made sure you register the DLL with
regasm "path to dll" /codebase /tlbIf you don’t register a TLB, I think VBA will not be able to find the object.From VBScript try
set myobj = CreateObject("FULLREFERENCE.CLASSNAME")you’ll need to experiment until you have the exact name.Then in your VBA code, add a referecnce to the tlb/dll depending on how you registered it.