Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Auto Install Analysis ToolPak

Status
Not open for further replies.

MikeAuz1979

Programmer
Aug 28, 2006
80
AU
Hey Y'all,

Using access 2000 I have a macro that installs the analysis toolpak (which is needed for some xl sheet calcs) [the code is below] and I thought it worked fine until I tried this code on a PC that had only just had office 2000 installed and found that this code appears to only swicth on the addin if it has already been installed. (Error is "Error in installation of addin class" from memory)

Does anyone have any ideas how to reliably install addins even if they haven't been installed already?

Thanks for any help
Mike

---Code Start---
Application.AddIns("Analysis ToolPak").Installed = True
---Code End---
 
Assume that Application=Excel. 'Install' is equivalent to mark given addin in addins list. If it is an optional install, you need an office installation disk to add it.

combo
 
Sorry your right I actually meant to write excel 2000 (I guess I'm too used to writing access!)

To clarify what I'm trying to mimic is on a fresh install of excel 2000 the user goes to Tools, Addins, clicks analysis toolpak, a pop-up says 'This feature isn't installed, install now?, user clicks yes and then it's ticked and the functions are available in excel. (Maybe disks aren't needed because my IT department has set this up already but I can assume that this is setup for all users.)

After the user has done this for the first time you can then click the addin on or off which the above code works for but it fails when the addin has never been installed before.

Anyone have any ideas?

Mike

 
Never tried to start fresh excel with vba.
It is be possible anyway that the default installation option was choosen. Maybe something can be done with api. If not, the users should manually add this addin. For new computers you should change installation settings.

From the ms website:
The Analysis ToolPak. Certain industries—including finance and engineering—rely heavily on this set of tools. The default installation state is Installed on First Use; you may want to change it to Run from My Computer. This feature is found in the Excel\Add-ins tree."

combo
 
Hi,

I've written something that would install a custom-addin.

You could probably modify it to do the same for the analysis toolpak (or at least get some ideas). I wrote it a long time ago, so I doubt it's most efficient way of doing it, but it might give you some pointers:

Code:
Sub CheckForAddin()

Dim DefaultAddinPath As String
Dim wbMyAddin As Workbook
Dim lastError As String

DefaultAddinPath = "C:\PathToAddin\"

On Error GoTo AddinInstall

If Application.AddIns("SupportProcedures").Installed = False Then
    Application.AddIns("SupportProcedures").Installed = True
End If

Application.StatusBar = "Ready"
On Error GoTo 0

Exit Sub

AddinInstall:

    On Error GoTo AddinUnavailable
    
    Application.AddIns.Add(DefaultAddinPath & "SupportProcedures.xla", False).Installed = True
    
    On Error Resume Next
    Set wbMyAddin = Workbooks(AddIns("SupportProcedures").Name)
    lastError = Err
    On Error GoTo 0
    If lastError <> 0 Then
        Set wbMyAddin = Workbooks.Open(AddIns("SupportProcedures").FullName)
    End If
    
    Set wbMyAddin = Nothing
    
    On Error GoTo 0
    Application.StatusBar = "Installation Complete"
    
    Exit Sub
    
AddinUnavailable:
    
        Beep
        MsgBox "Addin was not found!", vbOKOnly + vbCritical
    
End Sub

Cheers,

Roel
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top