Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

excel - Add in installed and referenced

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 Refernced i mean is Tools > Addins > Addins Dailog box > If addins is installed > check if a addin with particular name is checked.

I would like preferably without any loop.

Sub Demo() 
    Dim b As Boolean 
    b = CheckAddin("Solver add-in") 
    MsgBox "Solver is " & IIf(b, "", "not ") & "installed" 
End Sub 

Function CheckAddin(s As String) As Boolean 
    Dim x As Variant 
    On Error Resume Next 
    x = AddIns(s).Installed 
    On Error Goto 0 
    If IsEmpty(x) Then 
        CheckAddin = False 
    Else 
        CheckAddin = True 
    End If 
End Function 
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...