vbams-officecomaddin

Install an Excel COM Add-In with VBA


Is it possible to install a COM add-in using VBA? I've found another post that links to solutions for installing non-COM add-ins using VBA, but that's not working for COM add-ins. Not that it matters, but I'm specifically looking to script the installation of the Inquire COM add-in for Excel 2013.

Here's what I know doesn't work:

This is the code I've found for installing non-COM add-ins:

AddIns("NativeShim.InquireConnector.1").Installed = True

That code fails because I'm trying to work with a COM add-in and the specified add-in doesn't exist in that collection.

This is the code that I've tried with COM add-ins

Dim addin As COMAddIn
Set addin = COMAddIns.Item("NativeShim.InquireConnector.1")
addin.Installed = True

That code gets the reference to the add-in correctly but fails on setting Installed to True because COMAddIn objects don't have an Installed property.


Solution

  • Based on Excel 2010 you need to:

    1. Run Excel with Administrator privileges

    2. Connect to your add-in instead of setting .Installed property in this way:

      Application.COMAddIns("NativeShim.InquireConnector.1").Connect = True
      
    3. Setting .Connect property to false will obviously turn com add-in off.