Accessing a VSTO application-addin types from VBA (Excel) Accessing a VSTO application-addin types from VBA (Excel) vba vba

Accessing a VSTO application-addin types from VBA (Excel)


VSTO is not a DLL that can generally be called from other DLLs. VSTO is basically COM-exposed .NET code operating from within a wrapper operating from within a separate AppDomain. Although your VSTO add-in is technically a DLL that is being loaded into Excel, it operates more like a top-level EXE rather than as a DLL library exposed to other callers.

Personally, I would create a standard .NET assembly -- that is, avoid using VSTO for this -- and expose it to COM using the correct attributes. The process is well explained here: COM Interop Exposed - Part 2, under the section titled "Exposing .NET Events to COM".

If you really insist on enabling VBA to be able to call VSTO, then you'll have to operate via the Office.COMAddIn.Object property which is enabled by overriding the RequestComAddInAutomationService method. The process is discussed in detail in the article VSTO Add-ins, COMAddIns and RequestComAddInAutomationService by Andrew Whitechapel.

I hope this helps!

Mike