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
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
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
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