Macro_BeforeClose event...Possible??

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

Would it be possible to catch when a user prematurely ends a macro by 'Ctrl-Break'? I would like to reset the Statusbar (ie set it to False) before quitting the macro. I guess what I'm looking for is an event similar to the Workbook_BeforeClose..

Many thanks for any suggestions

SuperJas.
 
Take a look at Application.EnableCancelKey


--
Rob van Gelder - http://www.vangelder.co.nz/excel


SuperJas said:
Hi,

Would it be possible to catch when a user prematurely ends a macro by
'Ctrl-Break'? I would like to reset the Statusbar (ie set it to False)
before quitting the macro. I guess what I'm looking for is an event similar
to the Workbook_BeforeClose...
 
You can use the Application.EnableCancelKey property to control
how VBA responds to Ctrl+Break. For example

Application.EnableCancelKey = xlErrorHandler
On Error GoTo ErrHandler:
'
' your code here
'
Exit Sub
ErrHandler:
If Err.Number = 18 Then
MsgBox "You pressed break"
End If


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



SuperJas said:
Hi,

Would it be possible to catch when a user prematurely ends a
macro by 'Ctrl-Break'? I would like to reset the Statusbar (ie
set it to False) before quitting the macro. I guess what I'm
looking for is an event similar to the Workbook_BeforeClose...
 

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

Back
Top