ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   abort macro dialog box (https://www.excelbanter.com/excel-programming/328434-abort-macro-dialog-box.html)

Chris

abort macro dialog box
 
Hi there,

I have a little problem making an dialog box.
In my excel sheet i have a commandbutton who runs through my macro.
Since i don't want other people to abort the macro with Esc or
Ctrl-Break i have put this line in: Application.EnableCancelKey =
xlDisabled

But now people don't have the ability at all to stop the macro. For
some people i think this is anoying because the macro runs for about 2
á 3 minutes.

So what i want is 1 abort key, and when they hit this key there is a
dialog box whith a warning and a 'cancel' and a 'run macro further'
button, somthing like that.

Can someone give me some advice or point me in the right direction?

Nick

abort macro dialog box
 
The simplest way is to set the enablecancelkey property to xlErrorHandler
and trap the canel key press in an error handler.
You can then prompt them to cancel or continue.
If they press cancel then exit the procedure.
If they press run further then put the resume statement in the error
handler.

Hope this helps
Nick
"Chris" wrote in message
om...
Hi there,

I have a little problem making an dialog box.
In my excel sheet i have a commandbutton who runs through my macro.
Since i don't want other people to abort the macro with Esc or
Ctrl-Break i have put this line in: Application.EnableCancelKey =
xlDisabled

But now people don't have the ability at all to stop the macro. For
some people i think this is anoying because the macro runs for about 2
á 3 minutes.

So what i want is 1 abort key, and when they hit this key there is a
dialog box whith a warning and a 'cancel' and a 'run macro further'
button, somthing like that.

Can someone give me some advice or point me in the right direction?





All times are GMT +1. The time now is 12:34 AM.

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