I am writing a VBA Excel Add-in.
When the add-in is active, it defines some keyboard shortcuts with Application.OnKey. I would like to return these keyboard shortcuts to the default when the add-in closes, and I am using the Auto_Close method inside one of the add-in’s modules for this.
However, I have come across a problem:
When the user opens multiple regular workbooks while my add-in is loaded, and closes just one of them, the Auto_Close on the add-in seems to trigger and turn off the keyboard shortcuts in the other windows.
How can I only trigger an Auto_Close-equivalent when the add-in is completely unloaded (other than completely exiting Excel)?
Try using the
Workbook_OpenandWorkbook_BeforeCloseevents of the addin. I don’t know why Auto_Close would behave as you describe, but I’m sure the two above will work.