Closing Any Open Add Ins

When the user unchecks the SRXUtils item in the Add-Ins dialog, Excel will close the SRXUtils.xla workbook. But it will not close any add-ins, such as Print.utl, that were opened in code. The place to close all open add-ins is in the workbook's BeforeClose event, which currently only deletes the custom menu.

A simple (but perhaps not elegant) approach is to close every add-in listed in the DataSheet except the main SRXUtils.xla (which is closed when the user deselects the add-in). For this, we need an On Error Resume Next line so that an attempt to close a workbook that is not open will be ignored. Thus, you should change the code for the existing BeforeClose event to that shown in Example 12-16.

0 0

Post a comment