Interupt close


Posted by Christopher Mains on July 24, 2001 1:32 PM

I have a dialog box that comes up when I close an spreadsheet... I have one selection that I want to cancel the close process please I need help asap...

Posted by Cory on July 24, 2001 2:47 PM

It depends on what the dialog box is that pops up when you try to close. Say if you're using a msgbox with vbYesCancel then use the following code:

response = MsgBox("Do you want to close this book?", vbOKCancel, "Close?")
If response = vbCancel Then
Exit Sub
Else
ActiveWorkbook.Close
End If

If you're not using a msgbox then you can probably incorporate the code above into your dialog box somewhere...

Hope this helps

Cory



Posted by Joe Was on July 24, 2001 3:14 PM

Add this before your code:

Application.DisplayAlerts=False

then change the False to True after your code, this will make Excel choose the default option for the alert without displaying it. Test it, it works most of the time. JSW