Interference with the add-in's ribbon is not possible (or at least immoral
). As I mentioned earlier, you can disable the add-in.
This macro lists all COM add-ins installed in Excel and indicates whether the add-in is currently enabled. When working with programmatic enable/disable COM add-ins, use the progID property, not Description, although the latter is more human-friendly (but is prone to language conversions).
Sub OverviewCOMAddIns()
Dim addIn As COMAddIn
' Results in the Immediate window
For Each addIn In Application.COMAddIns
Debug.Print addIn.progID, addIn.Connect, Chr(34) & addIn.Description & Chr(34)
Next addIn
Debug.Print String(35, "=")
End Sub
To enable/disable an add-on, you can use the following function, which returns True when the action succeeded.
Sub Test()
If SwitchCOMAddIn("PowerPivotExcelClientAddIn.NativeEntry.1", True) Then
' is OK
Stop
Else
' Something went wrong
Stop
End If
End Sub
Function SwitchCOMAddIn(strprogID As String, blnConnect As Boolean) As Boolean
Dim addIn As COMAddIn
On Error Resume Next
Set addIn = Application.COMAddIns(strprogID)
On Error GoTo 0
If Not addIn Is Nothing Then
If (Not addIn.Connect) = blnConnect Then
addIn.Connect = blnConnect
End If
SwitchCOMAddIn = (addIn.Connect = blnConnect)
Else
SwitchCOMAddIn = False
End If
End Function
Artik