Add in installed and referenced

前端 未结 3 784
萌比男神i
萌比男神i 2020-12-21 11:38

I want to check if addin is installed and is referenced. The below code checks for add in is installed or not. How can i check if its referenced in excel.

By Refernc

相关标签:
3条回答
  • 2020-12-21 12:17
    Sub Sample()
        Dim wbAddin As Workbook
    
        On Error Resume Next
        Set wbAddin = Workbooks(AddIns("My Addin").Name)
    
        If Err.Number <> 0 Then
            On Error GoTo 0
            'Set wbAddin = Workbooks.Open(AddIns("My Addin").FullName)
            Debug.Print "Not Referenced"
        Else
            Debug.Print "Referenced"
        End If
    End Sub
    
    0 讨论(0)
  • 2020-12-21 12:31

    I've had a problem that even when the function returns True, I would still get an error when trying to use that addin. It turns out, an addin can be installed, but not "open". So, in addition to checking for the addin, I also check if the addin file is open. If not, I open the addin. See my question and answer here:

    Excel VBA Checking if Addin Is Installed But Not Open

    0 讨论(0)
  • 2020-12-21 12:35

    You need to test is the addin is open, pretty much like any other workbood. This will return True if an addin is loaded:

    Function AddinIsLoaded(AddinName As String) As Boolean
    On Error Resume Next
    AddinIsLoaded = Len(Workbooks(AddIns(AddinName).Name).Name) > 0
    End Function
    

    For example:

    Sub Test
    Debug.Print AddinIsLoaded("Solver add-in")
    End Sub
    
    0 讨论(0)
提交回复
热议问题