Thread: Automate Add-in
View Single Post
  #2   Report Post  
Jim Cone
 
Posts: n/a
Default

GS,

The following added to the "ThisWorkbook" module seems to work.
Note that if the module level variable value is lost then the
ToolPak will be left installed on Excel.
'---------------------------------------
Option Explicit

Private byteFlag As Byte

Private Sub Workbook_BeforeClose(Cancel As Boolean)
If byteFlag < 100 Then
Excel.AddIns("Analysis ToolPak").Installed = True
Else
Excel.AddIns("Analysis ToolPak").Installed = False
End If
End Sub

Private Sub Workbook_Open()
If Excel.AddIns("Analysis ToolPak").Installed Then
byteFlag = 99
Else
byteFlag = 123
Excel.AddIns("Analysis ToolPak").Installed = True
End If

End Sub
'-------------------------------------

Regards,
Jim Cone
San Francisco, USA


"Gary's Student" wrote in message
...
I distribute some workbooks that rely on the Analysis ToolPak. The
recipients have a problem if the ToolPak is not installed. Upon opening the
workbook, how can I :

1. Determine and remember if the ToolPak is already installed
2. Install the ToolPak if not already installed
3. Prior to closing the workbook, returning the ToolPak installation status
to what it was initially
--
Gary's Student