ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   ThisWorkBook BeforeClose Event (https://www.excelbanter.com/excel-programming/305376-re-thisworkbook-beforeclose-event.html)

Doug Glancy

ThisWorkBook BeforeClose Event
 
Carlos,

I like to put my call to the toolbar delete macro in the WorkbookDeactivate
module instead of the BeforeClose. In addition to solving your problem, it
also means that the toolbar goes away when you select/open a different
workbook. If you do this, you'll also need to call your toolbar create
macro in the WorkbookActivate event as well as the Open event, so that the
toolbar is created when you switch back to your workbook from the other one.

hth,

Doug Glancy

"Carlos Lozano" wrote in message
...
Hi,

My application creates a toolbar on Opening (this works fine) and I am

trying to delete it when the workbook is closed. I am calling the Toolbar's
delete method on the BeforeClose event of the ThisWorkBook Object.

The current behavior is below:
1) If the document was not modified, it works perfectly
2) If the document was modified, it prompts to save changes and if "yes"

or "No" are selected works fine. The BeforeClose event is executed as
expected.
2) If the document was modified, and "cancel" is selected the BeforeClose

event is executed. I wasn't expecting this as the workbook was not closed.
So, It deletes the toolbar and the workbook remains open (with no toolbar
which is a problem). The beforeClose event is executed before the message is
shown.

How can I know what was selected on the "Do you want to save..." message?

to choose the right action.

Thank you,

Carlos Lozano
CAX IT Services






All times are GMT +1. The time now is 06:06 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com