ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro_BeforeClose event...Possible?? (https://www.excelbanter.com/excel-programming/298900-macro_beforeclose-event-possible.html)

SuperJas

Macro_BeforeClose event...Possible??
 
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.

Frank Kabel

Macro_BeforeClose event...Possible??
 
Hi
AFAIK there's no such event

--
Regards
Frank Kabel
Frankfurt, Germany


SuperJas wrote:
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.



Rob van Gelder[_4_]

Macro_BeforeClose event...Possible??
 
Take a look at Application.EnableCancelKey


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


"SuperJas" wrote in message
...
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.




Chip Pearson

Macro_BeforeClose event...Possible??
 
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" wrote in message
...
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.





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

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