Overriding RequestComAddInAutomationService (Excel Ribbon Add-In)

Jan 9, 2013 at 9:37 AM

First of all thanks a lot for the NetOffice package and your support. I'm currently studying ribbon add-ins in Excel to see if it's a viable route for a project, but I'm having a problem with the execution of some of the add-in's functions from VBA.

I used your "Custom Ribbon Icons Example[Visual Basic]" project (http://netoffice.codeplex.com/wiki/PageInfo?title=Download%20Page) as basis for the addin and followed the instructions found here: http://msdn.microsoft.com/en-gb/library/vstudio/bb608614.aspx

However when trying to override RequestComAddInAutomationService in my Public Class Addin I get as error: "function 'RequestComAddInAutomationService' cannot be declared 'Overrides' because it does not override a function in a base class"

Should I do anything special for VBA <-> AddIn communication using NetOffice?



Jan 11, 2013 at 6:28 PM

sorry for the delay. i got no notifications at the moment for new discussions. nothing at all. NOT! :(

RequestComAddinAutomationService is a special VSTO service. VSTO is specific handmade framework from MS to use Office in .NET
NetOffice isn't an opponent to VSTO at the moment. NetOffice is just a substitute for the Interop Assemblies. but anyway, you can use it also in NetOffice(or Interop Assemblies)

1) define the IAddInUtilities/AddInUtilities, define also a guid attribute for the AddInUtilities class
2) fill the Object property in the OnConnection procedure
void ThisAddin_OnConnection(object Application, ext_ConnectMode ConnectMode, object AddInInst, ref Array custom){
    AddInInst.GetType().InvokeMember("Object", BindingFlags.SetProperty, null, AddInInst, new object[] {new AddInUtilities});

now you can use the addIn.Object in the same way from VBA.
please feel free to contact me again. (codeplex is in trouble at the moment, please contact me at public.sebastian@web.de)



Jan 15, 2013 at 9:39 AM

Thanks Sebastian, it worked like a charm. In case someone needs the VB version:

Public Sub OnConnection(ByVal Application As ObjectByVal ConnectMode As ext_ConnectMode, ByVal AddInInst As ObjectByRef custom As System.Array) Implements IDTExtensibility2.OnConnection

         ' Initialisation here ...

            AddInInst.GetType().InvokeMember("Object", BindingFlags.SetProperty, Nothing, AddInInst, New Object () { new AddInUtilities })

End Sub