You can access COM API of the add-in programmatically in one of the following ways:
•From Excel by using Visual Basic for Applications;
•From your custom program by using the Office Interop API from any .NET language.
The main interface is the IAutomationAPI interface. The code listing below shows how to create a new instance of the automation object in VBA:
Dim automationObject As Object
Set automationObject = Application.COMAddIns.Item("Altova.SolvencyIIAddIn").Object
Access COM API from a .NET project
To access the COM API from a Visual Studio .NET project, add a reference to the assemblies Microsoft Office Object Library (office.dll) and Microsoft.Office.Interop.Excel, as shown below:
1.Right-click your project's name in Solution Explorer and then click Add Reference. The Add Reference dialog box appears.
2.On the Assemblies page, select office and Microsoft.Office.Interop.Excel from the component list and click OK.
If you do not see the assemblies above, take the following steps:
1.Make sure that you have installed Microsoft Office and that you have selected the .NET Programmability Support feature for Excel (see screenshot below).
2.Run the Visual Studio setup and make sure that you choose the Office/SharePoint development workload or Microsoft Office Developer Tools, if applicable.
For more information about accessing Office interop assemblies from .NET projects, see the Microsoft documentation. After adding the assembly references, you can create a new add-in instance as shown below.
// Make sure that your project references the following two assemblies:
// * Microsoft.Office.InterOp.Excel
// * Microsoft Office Object Library (office.dll)
var app = new Microsoft.Office.Interop.Excel.Application();
dynamic automationObject = app.COMAddIns.Item("Altova.SolvencyIIAddIn").Object;