Events


Open and BeforeClose

There are two other workbook events that are relevant to creating add-ins.
These two events are fired when Excel is opened and closed with the add-in installed.
These subroutines are the best place for your initialisation and clean up code.
Be aware that these events will occur in addition to the above two events when an add-in is manually installed or removed from the (Tools > Add-ins) dialog box.


Open
This event is fired every time the add-in is loaded and Excel is opened.

Private Sub Workbook_Open() 
' Any initialisation code should be placed in here
End Sub

BeforeClose
This event is fired every time the add-in is loaded and Excel is closed.

Private Sub Workbook_BeforeClose() 
' Any clean up code should be placed in here
End Sub

AddinInstall and AddinUninstall

These two workbook events will occur when an add-in is initially installed or uninstalled.
These subroutines can be used to carry out one time initialisation tasks such as copying (or removing) templates.


AddinInstall
This event is only fired when an add-in is added (or ticked) in the (Tools > Add-ins) dialog box.
Once the add-in has been loaded this event will not be fired again.

Private Sub Workbook_AddinInstall() 
' Any initialisation code should be placed in here
End Sub

The Open event is fired immediately after this event.


AddinUninstall
This event is only fired when an add-in is removed (or unticked) from the (Tools > Add-ins) dialog box.

Private Sub Workbook_AddinUninstall() 
' Any clean up code should be placed in here
End Sub

The BeforeClose event is fired immediately after this event.



© 2020 Better Solutions Limited. All Rights Reserved. © 2020 Better Solutions Limited TopPrevNext