Thread: Control-Break
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Neptune Dinosaur Neptune Dinosaur is offline
external usenet poster
 
Posts: 46
Default Control-Break

Yeah, I thought of that, but user input is disabled by definiton while the
"demo" macro is running, and I need it to be disabled so that users can't
change the scenario that I am demonstating (so non-modal message boxes aren't
the answer. either). Ctrl-Brk seems to be the only viable interrupt. Can I
harness this neatly?
--
Time is just the thing that keeps everything from happening all at once


"JLGWhiz" wrote:

If I was doing it, I would use a command button that ties to a macro which
simply shuts the program down with Application.Quit. Put a caption on the
button that says EARLY TERMINATION.

Private Sub CommandButton1_Click()
ThisWorkbook.Saved = True
Application.Quit
End Sub

It does not alter the original workbook and can be invoked anywhere there is
a break in the code execution.

"Neptune Dinosaur" wrote:

G'day macrosaurs ....

I've had a good look around for the answer to this and can't find it, so I
promise I am not just being lazy in calling for help. I need to be able to
trap the Control-Break "event" when the user hits those keys to interrupt a
macro, in the same way (if possible) that you trap an error. I have a data
input/output application in Excel 2003/VBA that includes a "live demo" of how
to use the file. It runs for 2 - 3 minutes or even longer, depending on how
long the user lingers over the message boxes. I want the user to be able to
abort the demo at any time by hitting Ctrl-Brk without getting the scary run
time error that you normally get when you do that, i.e. I would like this to
be a neat, controlled exit (my users are not hightly IT-savvy).

An alternative that I was considering would be to actually provide Yes/No
message boxes at several strategic points throughout the demo, but it would
be nice to have the "leave at any time" option if possible.

Any ideas?
--
Time is just the thing that keeps everything from happening all at once