PDA

View Full Version : Solved: check for add in progmatically



austenr
08-03-2007, 04:45 PM
Is it possible to check for the existance of an add in using vba?

mikerickson
08-03-2007, 06:39 PM
For i = 1 To AddIns.Count
MsgBox AddIns(i).Name & " installed " & AddIns(i).Installed
Next i

There are other properties that can be found by searching on Addin in the Object Browser.

austenr
08-03-2007, 06:54 PM
OK. So now is it possible to check for a specific add in and if it is not installed install it? Probably could use the macro recorder to do the install but checking for a specific install is the part im stuck on.

mikerickson
08-03-2007, 08:23 PM
The Addings(index).Installed sometiems gives an error if index is a string, but always works if its an integer (long?).

If I was looking for "oneAddIN",


Sub test()
Dim addinName As String
Dim i As Integer, nameExists As Boolean
addinName = "oneAddIN":Rem caps sensitive
For i = 1 To AddIns.Count
If AddIns(i).Name = addinName Then nameExists = True: Exit For
Next i
If nameExists Then
AddIns(i).Installed = True
Else
Application.Dialogs(xlDialogAddinManager).Show
End If
End Sub
If you have the full path to the addin, you could use .Add instead of calling the dialog.

austenr
08-03-2007, 09:03 PM
Thanks. Looking for the Solver addin in 2007. I have created a custom menu and wanted to make one of the options to check for it and depending on the result if not found add it via code.