Analysis ToolPak

The following line may not work with non-English user interfaces since the name might have been localised

Addins("Analysis-ToolPak").Installed = True 

Calling Analysis ToolPak Functions

There are two ways you can call these functions in Excel 2003

value = Application.Run("MRound",10,3) = 9 
value = Application.WorksheetFunction.MRound(10,3) = 9

In Excel 2007 you should only use the second method.
The first one will generate a run-time error



Public Function Addin_ATP_Installed(ByVal bCheckAddin As Boolean, _ 
                                    ByVal bCheckVBAAddin As Boolean) As Boolean
Dim ldate As Long
   On Error GoTo AnError
   If bCheckAddin = True Then
      ldate = Application.Run("EOMONTH", "01/01/1977", 1)
   End If
   
   If bCheckVBAAddin = True Then
      ldate = Application.Run("atpvbaen.xla!EOMONTH", "01/01/1977", 1)
   End If
   
   Addins_ATP_Installed = True
   Exit Function
AnError:
   Addins_ATP_Installed = False
End Function


Public Sub Addin_ATP_Load(ByVal bLoadAddin As Boolean, _ 
                          ByVal bLoadVBAAddin As Boolean, _
                 Optional ByVal bInformUser As Boolean = True)
Dim objaddin As AddIn
 
   On Error GoTo AnError
   
   For Each objaddin In AddIns
     If bLoadAddin = True Then
        If UCase(objaddin.Name) = "ANALYS32.XLL" Then
           objaddin.Installed = True
           If bInformUser = True Then
              Call MsgBox("'Analysis-ToolPak' add-in has been loaded.")
           End If
        End If
     End If
     
     If bLoadVBAAddin = True Then
        If UCase(objaddin.Name) = "ATPVBAEN.XLA" Then
           objaddin.Installed = True
           If bInformUser = True Then
              Call MsgBox("'Analysis-ToolPak - VBA' add-in has been loaded.")
           End If
        End If
     End If
   Next objaddin
   
'The following line may not work with non-English user interfaces since the name might have been localised
Addins("Analysis-ToolPak").Installed = True
   
   Exit Sub
   
AnError:
 
End Sub

Normal Circumstances




When a Com Add-in is loaded

Add-ins remain loaded even after they have been unchecked from (Tools > Addins) dialog box.



For more details about the VBA equivalent to some of the Analysis-ToolPak functions




© 2020 Better Solutions Limited. All Rights Reserved. © 2020 Better Solutions Limited TopPrev