PC Review


Reply
Thread Tools Rate Thread

Code to install Analysis ToolPak at Workbook Open

 
 
=?Utf-8?B?cm9iczMxMzE=?=
Guest
Posts: n/a
 
      8th Oct 2007
Hi,

I need to have Analysis Toolpak auto-installed when my workbook is opened --
I tried to modify code that I have to auto-install Solver (which works for
Solver), however, it is not working for Analysis ToolPak. Any idea why this
is not working? FYI - the original code to install Solver was copied from
"Peltier Technical Services" website
(http://peltiertech.com/Excel/SolverVBA.html).

Public Function CheckAntoolpak() As Boolean
'' Adjusted for Application.Run() to avoid Reference problems with
Analysis ToolPak
'' Peltier Technical Services, Inc., Copyright © 2007. All rights reserved.
'' Returns True if Analysis ToolPak can be used, False if not.

Dim bantoolpakInstalled As Boolean

If gbDebug Then Debug.Print Now, "Checkantoolpak "
'' Assume true unless otherwise
CheckAntoolpak = True

On Error Resume Next
' check whether Analysis ToolPak is installed
bantoolpakInstalled = Application.AddIns("Analysis ToolPak
Add-In").Installed
Err.Clear

If bantoolpakInstalled Then
' uninstall temporarily
Application.AddIns("Analysis ToolPak Add-In").Installed = False
' check whether Analysis ToolPak is installed (should be false)
bantoolpakInstalled = Application.AddIns("Analysis ToolPak
Add-In").Installed
End If

If Not bantoolpakInstalled Then
' (re)install Analysis ToolPak
Application.AddIns("Analysis ToolPak Add-In").Installed = True
' check whether Analysis ToolPak is installed (should be true)
bantoolpakInstalled = Application.AddIns("Analysis ToolPak
Add-In").Installed
End If

If Not bantoolpakInstalled Then
MsgBox "Analysis ToolPak not found. This workbook will not work.",
vbCritical
CheckAntoolpak = False
End If

If CheckAntoolpak Then
' initialize Analysis ToolPak
Application.Run "Analysis ToolPak.xla!Analysis ToolPak.Auto_open"
End If

On Error GoTo 0

End Function

--
Robert
 
Reply With Quote
 
 
 
 
Peter T
Guest
Posts: n/a
 
      8th Oct 2007
Hi Robert,

Try changing -

"Analysis ToolPak Add-In"
to
"Analysis ToolPak"

or, if you want the ATP addin for use with VBA
"Analysis ToolPak - VBA"

Regards,
Peter T

"robs3131" <(E-Mail Removed)> wrote in message
news:67361D39-6698-46A8-BEDA-(E-Mail Removed)...
> Hi,
>
> I need to have Analysis Toolpak auto-installed when my workbook is

opened --
> I tried to modify code that I have to auto-install Solver (which works for
> Solver), however, it is not working for Analysis ToolPak. Any idea why

this
> is not working? FYI - the original code to install Solver was copied from
> "Peltier Technical Services" website
> (http://peltiertech.com/Excel/SolverVBA.html).
>
> Public Function CheckAntoolpak() As Boolean
> '' Adjusted for Application.Run() to avoid Reference problems with
> Analysis ToolPak
> '' Peltier Technical Services, Inc., Copyright © 2007. All rights

reserved.
> '' Returns True if Analysis ToolPak can be used, False if not.
>
> Dim bantoolpakInstalled As Boolean
>
> If gbDebug Then Debug.Print Now, "Checkantoolpak "
> '' Assume true unless otherwise
> CheckAntoolpak = True
>
> On Error Resume Next
> ' check whether Analysis ToolPak is installed
> bantoolpakInstalled = Application.AddIns("Analysis ToolPak
> Add-In").Installed
> Err.Clear
>
> If bantoolpakInstalled Then
> ' uninstall temporarily
> Application.AddIns("Analysis ToolPak Add-In").Installed = False
> ' check whether Analysis ToolPak is installed (should be false)
> bantoolpakInstalled = Application.AddIns("Analysis ToolPak
> Add-In").Installed
> End If
>
> If Not bantoolpakInstalled Then
> ' (re)install Analysis ToolPak
> Application.AddIns("Analysis ToolPak Add-In").Installed = True
> ' check whether Analysis ToolPak is installed (should be true)
> bantoolpakInstalled = Application.AddIns("Analysis ToolPak
> Add-In").Installed
> End If
>
> If Not bantoolpakInstalled Then
> MsgBox "Analysis ToolPak not found. This workbook will not work.",
> vbCritical
> CheckAntoolpak = False
> End If
>
> If CheckAntoolpak Then
> ' initialize Analysis ToolPak
> Application.Run "Analysis ToolPak.xla!Analysis ToolPak.Auto_open"
> End If
>
> On Error GoTo 0
>
> End Function
>
> --
> Robert



 
Reply With Quote
 
=?Utf-8?B?cm9iczMxMzE=?=
Guest
Posts: n/a
 
      9th Oct 2007
Thanks Peter! That fixed it!

--
Robert


"Peter T" wrote:

> Hi Robert,
>
> Try changing -
>
> "Analysis ToolPak Add-In"
> to
> "Analysis ToolPak"
>
> or, if you want the ATP addin for use with VBA
> "Analysis ToolPak - VBA"
>
> Regards,
> Peter T
>
> "robs3131" <(E-Mail Removed)> wrote in message
> news:67361D39-6698-46A8-BEDA-(E-Mail Removed)...
> > Hi,
> >
> > I need to have Analysis Toolpak auto-installed when my workbook is

> opened --
> > I tried to modify code that I have to auto-install Solver (which works for
> > Solver), however, it is not working for Analysis ToolPak. Any idea why

> this
> > is not working? FYI - the original code to install Solver was copied from
> > "Peltier Technical Services" website
> > (http://peltiertech.com/Excel/SolverVBA.html).
> >
> > Public Function CheckAntoolpak() As Boolean
> > '' Adjusted for Application.Run() to avoid Reference problems with
> > Analysis ToolPak
> > '' Peltier Technical Services, Inc., Copyright © 2007. All rights

> reserved.
> > '' Returns True if Analysis ToolPak can be used, False if not.
> >
> > Dim bantoolpakInstalled As Boolean
> >
> > If gbDebug Then Debug.Print Now, "Checkantoolpak "
> > '' Assume true unless otherwise
> > CheckAntoolpak = True
> >
> > On Error Resume Next
> > ' check whether Analysis ToolPak is installed
> > bantoolpakInstalled = Application.AddIns("Analysis ToolPak
> > Add-In").Installed
> > Err.Clear
> >
> > If bantoolpakInstalled Then
> > ' uninstall temporarily
> > Application.AddIns("Analysis ToolPak Add-In").Installed = False
> > ' check whether Analysis ToolPak is installed (should be false)
> > bantoolpakInstalled = Application.AddIns("Analysis ToolPak
> > Add-In").Installed
> > End If
> >
> > If Not bantoolpakInstalled Then
> > ' (re)install Analysis ToolPak
> > Application.AddIns("Analysis ToolPak Add-In").Installed = True
> > ' check whether Analysis ToolPak is installed (should be true)
> > bantoolpakInstalled = Application.AddIns("Analysis ToolPak
> > Add-In").Installed
> > End If
> >
> > If Not bantoolpakInstalled Then
> > MsgBox "Analysis ToolPak not found. This workbook will not work.",
> > vbCritical
> > CheckAntoolpak = False
> > End If
> >
> > If CheckAntoolpak Then
> > ' initialize Analysis ToolPak
> > Application.Run "Analysis ToolPak.xla!Analysis ToolPak.Auto_open"
> > End If
> >
> > On Error GoTo 0
> >
> > End Function
> >
> > --
> > Robert

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Install Analysis ToolPak Alex Microsoft Excel Programming 2 11th Dec 2007 09:51 PM
Macro to enable the analysis toolpak VBA addin on entering a workbook?? bsnapool Microsoft Excel Programming 2 15th Jul 2006 11:41 AM
Why can't I install Analysis ToolPak in my Excel? =?Utf-8?B?Q2hyaXN0YSBBbGZvcmQ=?= Microsoft Excel Crashes 1 26th May 2006 07:29 AM
Cannot install add-in Analysis ToolPak quanghoc@gmail.com Microsoft Excel Discussion 0 17th Jan 2006 12:10 AM
can I install Analysis toolPak into my Excel 97? tony lincoln Microsoft Excel Misc 2 7th Nov 2003 07:46 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:05 PM.