I found this code on the web - it stops the user from crashing the program by using Ctrl+break
It seems like a good idea - but I am wondering if this is a good concept - any comments would be appreciated.
It seems like a good idea - but I am wondering if this is a good concept - any comments would be appreciated.
Code:
[FONT=Lucida Console]Sub another_code_that_runs_5_seconds()[/FONT]
[FONT=Lucida Console]On Error GoTo MyErrorHandler:[/FONT]
[FONT=Lucida Console]t = Timer[/FONT]
[FONT=Lucida Console]Application.EnableCancelKey = xlErrorHandler[/FONT]
[FONT=Lucida Console]Do While Timer - t < 5[/FONT]
[FONT=Lucida Console]Loop[/FONT]
[FONT=Lucida Console]MsgBox 1[/FONT]
[FONT=Lucida Console]Application.EnableCancelKey = xlInterrupt[/FONT]
[FONT=Lucida Console]Do While Timer - t < 10[/FONT]
[FONT=Lucida Console]Loop[/FONT]
[FONT=Lucida Console]MyErrorHandler:[/FONT]
[FONT=Lucida Console]If Err.Number = 18 Then[/FONT]
[FONT=Lucida Console] MsgBox "Stop hitting ctrl + break"[/FONT]
[FONT=Lucida Console] Resume[/FONT]
[FONT=Lucida Console]Else[/FONT]
[FONT=Lucida Console] 'Do something to make your impatient user happy[/FONT]
[FONT=Lucida Console]End If[/FONT]
[FONT=Lucida Console]End Sub[/FONT]
Last edited: