Consulting

Results 1 to 4 of 4

Thread: Method of Monitoring a Workbook's Addin Collection

  1. #1
    VBAX Newbie
    Joined
    Feb 2008
    Posts
    4
    Location

    Method of Monitoring a Workbook's Addin Collection

    Hi Everybody,

    I'm trying to write a sub routine that execute immediately after a particular Addin is installed or uninstalled. The Addin in question is closed source, so I can not add methods or events directly to it.

    Can anybody suggest an approach?

    Thanks,
    Chris

  2. #2
    You can create an application object as "withevents" in the thisworkbook module of whatever you're writing your macro in (workbook, addin, etc...) and set up the WorkbookAddinInstall event in it. Basically just set up some code like so:

    Private WithEvents XLApp as Excel.Application

    Sub SetUpAddInWatch()
    Set XLApp = Application
    End Sub

    Private Sub XLApp_WorkbookAddinInstall(ByVal Wb As Workbook)
    'Execute your code here to see if the addin has been installed
    End Sub

    Private Sub XLApp_WorkbookAddinUninstall(ByVal Wb As Workbook)
    'Execute more code here when the addin is uninstalled
    End Sub

    Note that when your addin/workbook opens (the one you're writing) you need to call the SetUpAddinWatch sub to set a reference to the Excel application object. You can make this call like so (put this code in the ThisWorkbook module as well)

    Private Sub Workbook_Open()
    SetUpAddInWatch
    End Sub

  3. #3
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    You can avoid the call to SetUpAdinWatch by putting that code directly in Wokbook_Open.

    But ... this technique assumes that this workbook gets opened befoea all the addins.
    ____________________________________________
    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

  4. #4
    VBAX Newbie
    Joined
    Feb 2008
    Posts
    4
    Location
    Thank you both so much for your help. This approach works perfectly.

    Cheers,
    Chris

Posting Permissions

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