Consulting

Results 1 to 4 of 4

Thread: Solved: Trying to uninstall addin when closing file

  1. #1
    VBAX Regular
    Joined
    Feb 2008
    Location
    atlanta
    Posts
    20
    Location

    Solved: Trying to uninstall addin when closing file

    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.

    [VBA]
    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
    [/VBA]

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    ARe you sure you ave the correct addin title? Remove the On Error and see what happens.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    The second sub does not get called. Why not
    [VBA]Private Sub Workbook_BeforeClose(Cancel As Boolean)
    Application.AddIns("IclAddIn").Installed = False
    End Sub
    [/VBA]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  4. #4
    VBAX Regular
    Joined
    Feb 2008
    Location
    atlanta
    Posts
    20
    Location
    thank you. this seems to work the way i want it to. have a good day.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •