Avoiding AddIn unloading upon excel closure when 'Cancel' button is hit on a workbook

  • Thread starter Thread starter tupolev
  • Start date Start date
T

tupolev

Hello,
I need some help on AddIn programming.
I would like to avoid that my addin is unloaded by excel until all
workbooks are closed. Basically I would like to avoid that the user,
after chosing to close Excel and then changing his mind with a click
on Cancel button for one of the spreadsheets, has to load the AddIn
again to restore operativity.

Can anybody please help me?

Thanks
 
Hi

Sounds like you are using the Wrong Events for the Add-in. An Excel
Add-ins, once installed, should stay installed until the user go back to
Tools>Add-ins and unchecks it.

Basically, the add-in itself should have code like;

Private Sub Workbook_AddinInstall()
Run "AddMenus"
End Sub

Private Sub Workbook_AddinUninstall()
Run "DeleteMenu"
End Sub

In the Private Module of the Workbook Object, "ThisWorkbook".

See this page for some details
http://www.ozgrid.com/VBA/excel-add-in-create.htm

***** Posted via: http://www.ozgrid.com
Excel Templates, Training & Add-ins.
Free Excel Forum http://www.ozgrid.com/forum *****
 
Dave Hawley said:
...if for some reason this Add-in should only be available to the one
Workbook, make use of the Workbook_Activate and Deactivate Events over
the BeforeClose

***** Posted via: http://www.ozgrid.com
Excel Templates, Training & Add-ins.
Free Excel Forum http://www.ozgrid.com/forum *****

No no no.

Maybe I explained myself not clearly enough.
I am not telling that the addin gets uninstalled!
I am saying that the addin is unloaded (so, for instance, the menu
that I normally show on the menu bar, disappears). The addin is still
on the list of addins(and checked also), but has to be unchecked and
then checked again to work appropriately again. What I saw when
debugging the beforeclose event is that the workbook shown on the vb
project relative to the addin is closed before the workbooks visible
on the excel main window. So, when the user 'cancels' the closing of
excel, my addin is 'closed' while excel is not.
 
Back
Top