Add-in closes first when Excel is closed, causing problems

A

Arne

I have an add-in whose workbook_beforeclose event closes a toolbar that is
attached to the add-in. When a user closes Excel, it appears that the event
is closed as one of the first, and the toolbar is deleted. However, if the
user has made changes to other workbooks, he is asked whether he wants to
save them and upon canceling this operation, Excel remains active as does the
add-in. The toolbar is gone and cannot be made visible again as it has been
deleted. The only way is to close and restart excel. When Excel is really
closed after the aborted first time, an error occurs, because the
workbook_beforeclose event now tries to delete an already deleted toolbar. Is
there a way to solve this problem?

Thanks in advance,
 
R

Robert Flanagan

Why delete the toolbar? The add-in will load again when you open Excel.

You can put an "On Error Resume Next" statement in front of the delete
statement and "On Error Goto 0" right after. This will stop the error msg.

Robert Flanagan
http://www.add-ins.com
Productivity add-ins and downloadable books on VB macros for Excel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top