Enable COM addins in Excel through VBA

后端 未结 3 835
面向向阳花
面向向阳花 2020-12-21 14:14

I need to enable COM addins through VBA. The addins already exists under COM addins, but become unchecked when Excel crashes.

Sub hyp()
    Dim objAddIn As O         


        
3条回答
  •  借酒劲吻你
    2020-12-21 15:03

    Note: Please see the comment of BigBen below - this approach may not always work as the indexer does not always coincide with the description. If you need to search by description, then the Excel Developers answer is probably applicable (though I haven't personally tried it or needed it).


    A simpler alternative to the answer of Excel Developers that worked for me is to index the com add in directly by its string name instead of looping through the com add ins using an integer index and comparing to the description. In particular, this code worked for me (I've included a connect and disconnect version):

    Public Sub Connect_COM_AddIn(Name As String)
        Application.COMAddIns(Name).Connect = True
    End Sub
    
    Public Sub Disconnect_COM_AddIn(Name As String)
        Application.COMAddIns(Name).Connect = False
    End Sub
    

提交回复
热议问题