BeforeClose Problem

A

a.ohlund

Hi everyone,
I could use some help finding a proper alternative to BeforeClose.

As I've read in other threads it is known to cause problem and so it
does for me as well (the whole application crashing for example).

The problem is that I need to catch the event caused by a user clicking
the [x] to close a wb. I'm saving some data to DB and need to prompt
the user some alternatives when closing (yes/no/cancel), ie I need to
catch 'cancel', this is why I can't use Auto_Close...

I hope any of you people can help me!

Thanks!
/Anders
 
J

Jim Rech

ie I need to catch 'cancel', this is why I can't use Auto_Close...

I think you can use Before_Close if I'm following you. For example:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim Resp As Integer
Resp = MsgBox("Save data?", vbYesNoCancel)
Select Case Resp
Case vbCancel
Cancel = True
Case vbYes
''do save...
Case vbNo
''do whatever
End Select
End Sub



--
Jim
| Hi everyone,
| I could use some help finding a proper alternative to BeforeClose.
|
| As I've read in other threads it is known to cause problem and so it
| does for me as well (the whole application crashing for example).
|
| The problem is that I need to catch the event caused by a user clicking
| the [x] to close a wb. I'm saving some data to DB and need to prompt
| the user some alternatives when closing (yes/no/cancel), ie I need to
| catch 'cancel', this is why I can't use Auto_Close...
|
| I hope any of you people can help me!
|
| Thanks!
| /Anders
|
 

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

Similar Threads

BeforeClose Event problem 2
BeforeClose vs Auto_Close 16
BeforeClose problem 1
BeforeClose Event 1
BeforeClose order of events? 1
Add-In Menu Handling 3
BeforeClose event help 3
Infinite loop cancelling BeforeSave 10

Top