M
Matthew Pfluger
I am building a setup workbook that installs some custom addins. One of the
addins is giving me problems. The addin contains an Autpen procedure as
follows (note the DEBUG line at the end):
Public Sub Autpen()
' Initialize variables
Const szSOURCE As String = "Autpen" ' Module location
string for errorhandler
Dim bOpenFailed As Boolean ' Errorhandler
variable if commandbar code failed
On Error GoTo ErrorHandler
Application.ScreenUpdating = False
' Do stuff: build commandbars, register UDFs, etc.
ErrorExit:
On Error Resume Next
ResetAppProperties
If bOpenFailed Then ShutdownApplication
Debug.Print "I completed the startup code!!!"
Exit Sub
ErrorHandler:
bOpenFailed = True
Resume ErrorExit
End Sub
The Setup Workbook contains this code snippet in its Install procedure:
' Attempt to uninstall addin to make sure it's gone (see uninstall code
below)
On Error Resume Next
If Not bUninstallAddin(sAddinName) Then Err.Raise glHANDLED_ERROR
On Error GoTo ErrorHandler
' Install addin
With AddIns.Add(Filename:=sAddinSourceFilepath, CopyFile:=bCopyToLibrary)
.Installed = True
End With
' *************** UNINSTALL CODE ************
' Attempt to close addin in case it is open
On Error Resume Next
AddIns(sAddinName).Installed = False
On Error GoTo ErrorHandler
' Delete registry keys (if any)
If Not bDeleteAddinRegistryKey(sAddinName) Then Err.Raise glHANDLED_ERROR
' *************** UNINSTALL CODE ************
I know from testing that the Uninstall code completely uninstalls the addin,
including running its Auto_Close script.
If the addin has been previously uninstalled, the Install code executes
completely, including running the addin's Autpen script. If I step
through the Install procedure, the addin installs completely, including
running the Autpen script. I know the Autpen script runs because the
DEBUG line prints a record of the execution in the Immediate Window.
However, in the case where the addin is already installed and I run the
Install macro without stepping through, the addin is installed at the end,
but the Autpen macro doesn't run (no record in Immediate Pane). A check
in the Add-In Manager and the VBE reveals that the addin is in fact open, but
why wouldn't the Autpen script run under these circumstances?
I know this is a little OCD, but the end user could initiate this situation
and would likely freak out, so I'm trying to cover all bases. Thanks for any
input.
Matthew Pfluger
addins is giving me problems. The addin contains an Autpen procedure as
follows (note the DEBUG line at the end):
Public Sub Autpen()
' Initialize variables
Const szSOURCE As String = "Autpen" ' Module location
string for errorhandler
Dim bOpenFailed As Boolean ' Errorhandler
variable if commandbar code failed
On Error GoTo ErrorHandler
Application.ScreenUpdating = False
' Do stuff: build commandbars, register UDFs, etc.
ErrorExit:
On Error Resume Next
ResetAppProperties
If bOpenFailed Then ShutdownApplication
Debug.Print "I completed the startup code!!!"
Exit Sub
ErrorHandler:
bOpenFailed = True
Resume ErrorExit
End Sub
The Setup Workbook contains this code snippet in its Install procedure:
' Attempt to uninstall addin to make sure it's gone (see uninstall code
below)
On Error Resume Next
If Not bUninstallAddin(sAddinName) Then Err.Raise glHANDLED_ERROR
On Error GoTo ErrorHandler
' Install addin
With AddIns.Add(Filename:=sAddinSourceFilepath, CopyFile:=bCopyToLibrary)
.Installed = True
End With
' *************** UNINSTALL CODE ************
' Attempt to close addin in case it is open
On Error Resume Next
AddIns(sAddinName).Installed = False
On Error GoTo ErrorHandler
' Delete registry keys (if any)
If Not bDeleteAddinRegistryKey(sAddinName) Then Err.Raise glHANDLED_ERROR
' *************** UNINSTALL CODE ************
I know from testing that the Uninstall code completely uninstalls the addin,
including running its Auto_Close script.
If the addin has been previously uninstalled, the Install code executes
completely, including running the addin's Autpen script. If I step
through the Install procedure, the addin installs completely, including
running the Autpen script. I know the Autpen script runs because the
DEBUG line prints a record of the execution in the Immediate Window.
However, in the case where the addin is already installed and I run the
Install macro without stepping through, the addin is installed at the end,
but the Autpen macro doesn't run (no record in Immediate Pane). A check
in the Add-In Manager and the VBE reveals that the addin is in fact open, but
why wouldn't the Autpen script run under these circumstances?
I know this is a little OCD, but the end user could initiate this situation
and would likely freak out, so I'm trying to cover all bases. Thanks for any
input.
Matthew Pfluger