View Full Version : Method of Monitoring a Workbook's Addin Collection
zaprat2
12-18-2008, 12:54 PM
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
jfournier
12-18-2008, 02:46 PM
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
Bob Phillips
12-18-2008, 03:48 PM
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.
zaprat2
12-18-2008, 04:01 PM
Thank you both so much for your help. This approach works perfectly.
Cheers,
Chris
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.