PDA

View Full Version : Solved: Trying to uninstall addin when closing file



abhiker
07-14-2008, 01:01 PM
i am trying to uninstall an addin when i close my file. when i open certain files, i install it then. so i don't alway need the addin. this is the code i tried to use but it doesn't seem to do it. any help is greatly appreciated.


Dim bIsClosing As Boolean

' in case the user cancel the file close
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Cancel = False
bIsClosing = Not Cancel
End Sub

Private Sub Workbook_Deactivate()
On Error Resume Next
If bIsClosing = True Then
Application.AddIns("IclAddIn").Installed = False
End If
On Error GoTo 0
End Sub

Bob Phillips
07-14-2008, 01:38 PM
ARe you sure you ave the correct addin title? Remove the On Error and see what happens.

mdmackillop
07-14-2008, 01:59 PM
The second sub does not get called. Why not
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.AddIns("IclAddIn").Installed = False
End Sub

abhiker
07-15-2008, 05:08 AM
thank you. this seems to work the way i want it to. have a good day.