Test For Add-Ins

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have created a number of automated reports in Excel and now need to pass
the actual report generation on to a team of Analysts.

I order for these reports to run correctly, the user must have the “Analysis
ToolPak†and the “Analysis ToolPak-VBA†installed on their machine.

Is there a way I can test to see if these are installed without making the
user physically go to Tools>Add-Ins and looking?

Thanks for your help!
 
This will ensure the addins is being used.

On Error Resume Next ' turn off error checking
Set wbMyAddin = Workbooks(AddIns("analysis toolpak").Name)
lastError = Err
On Error GoTo 0 ' restore error checking
If lastError <> 0 Then
' the add-in workbook isn't currently open. Manually open it.
Set wbMyAddin = Workbooks.Open(AddIns("analysis toolpak").FullName)
End If
 
Normally the ATP addins should already exist in Addins collection (addin
manager ticked or unticked), though if not would need to be installed into
the collection via Office setup.

The second usage of the term 'installed', in context with addins, is to
actually load the addin. Following assumes the addin is already in the
Addins collection and if necessary loads it into Excel.

Sub InstalATP()
Dim sTitle As String
Dim adn As AddIn
Const ATP As String = "Analysis ToolPak"
Const ATP_VBA As String = "Analysis ToolPak - VBA"

On Error GoTo errH
sTitle = ATP
Set adn = Application.AddIns(sTitle)
If Not adn.Installed Then adn.Installed = True
If Not adn.Installed Then Err.Raise 12345

Set adn = Nothing
sTitle = ATP_VBA
Set adn = Application.AddIns(sTitle)
If Not adn.Installed Then
Application.SendKeys "{ESC}"
adn.Installed = True
End If
If Not adn.Installed Then Err.Raise 12345

Exit Sub
errH:
If adn Is Nothing Then
MsgBox sTitle & " does not appear to exist in the Addin manager"
Else
MsgBox "Problem installing " & sTitle
End If

End Sub

Regards,
Peter T
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top