Sub DisableComAddIns()
Dim objComAddIn As COMAddIn, sRegKey As String, IsReloadMsg As Boolean
On Error Resume Next
With CreateObject("WScript.Shell")
For Each objComAddIn In Application.COMAddIns
If objComAddIn.Connect Then
sRegKey = "HKEY_CURRENT_USER\Software\Microsoft\Office\Excel\AddIns\" & objComAddIn.progID & "\LoadBehavior"
Err.Clear
objComAddIn.Connect = False
If Err Then
IsReloadMsg = True
.RegWrite sRegKey, 2, "REG_DWORD"
End If
End If
Next
End With
If IsReloadMsg Then
MsgBox "Reload Excel to apply COM Add-Ins disconnecting"
Else
MsgBox "COM Add-Ins have been disconnected"
End If
End Sub