Results 1 to 5 of 5
  1. #1
    Silver Lounger
    Join Date
    Dec 2000
    Location
    California, USA
    Posts
    1,758
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Analysis Tookpak (03)

    I use the following code to test to see if the Analysis TookPak and VBA are appropriately checked. What I encounter is the code crashing if the addin is not installed. Is there a way to test to see if it is installed? If so, then the next logical step would be for it to be installed.

    Private Sub Workbook_Open()
    If AddIns("Analysis ToolPak - VBA").Installed = False Then AddIns("Analysis ToolPak - VBA").Installed = True
    If AddIns("Analysis ToolPak").Installed = False Then AddIns("Analysis ToolPak").Installed = True
    End Sub


    Thanks,
    John

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Analysis Tookpak (03)

    It runs OK on my PC, whether the add-ins are installed or not. Do you get an error message with End, Debug and Help buttons, or does Excel really crash?

  3. #3
    Silver Lounger
    Join Date
    Dec 2000
    Location
    California, USA
    Posts
    1,758
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Analysis Tookpak (03)

    Hans,

    Excel itself does not crash just the VBA code. Apparently if the toolpak is not installed the code has issues.

    Regards,
    John

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Analysis Tookpak (03)

    Try changing the code to

    Private Sub Workbook_Open()
    If AddIns("Analysis ToolPak").Installed = False Then
    AddIns("Analysis ToolPak").Installed = True
    End If
    If AddIns("Analysis ToolPak - VBA").Installed = False Then
    AddIns("Analysis ToolPak - VBA").Installed = True
    End If
    End Sub

    When you get an error message, click Debug and see which line causes the problem and report this in a reply.

  5. #5
    2 Star Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    199
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Re: Analysis Tookpak (03)

    John,

    This is code I have used successfully to handle the Analysis Toolpack either not loaded or not ticked when it is needed:

    <code>
    ' Set the Analysis Toolpack Add-in to be loaded, especially if
    ' not currently active.
    If AddIns.Item("Analysis ToolPak").Installed = False Then
    AddIns("Analysis Toolpak").Installed = True
    End If
    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
    </code>

    Good Luck!

    Peter Moran

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •