Thread: Control-Break
View Single Post
  #13   Report Post  
Posted to microsoft.public.excel.programming
Jim Cone[_2_] Jim Cone[_2_] is offline
external usenet poster
 
Posts: 1,549
Default Control-Break


Glad you got it working. Can't wait to see that next feature.<g
Following is from the xl97 help file for EnableCancelKey...

----
"Controls how Microsoft Excel handles CTRL+BREAK
(or ESC or COMMAND+PERIOD) user interruptions to the running procedure.
Read/write Long.

Can be one of the following XlEnableCancelKey constants.
xlDisabled Cancel key trapping is completely disabled.

xlInterrupt The current procedure is interrupted,
and the user can debug or end the procedure.

xlErrorHandler The interrupt is sent to the running procedure as an error,
trappable by an error handler set up with an On Error GoTo statement.
The trappable error code is 18.
Remarks
Use this property very carefully.
If you use xlDisabled, there's no way to interrupt a runaway loop or other
non €“ self-terminating code.
Likewise, if you use xlErrorHandler but your error handler always returns
using the Resume statement, there's no way to stop runaway code.

The EnableCancelKey property is always reset to xlInterrupt
whenever Microsoft Excel returns to the idle state and there's no code running.

To trap or disable cancellation in your procedure, you must explicitly change
the EnableCancelKey property every time the procedure is called."
----

Also...
Maybe your tech people just don't fully install the VBA help files and the
file are just waiting for their call to duty.
If so, another post of mine... http://tinyurl.com/6exe4z
'--
Jim Cone
Portland, Oregon USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)






"Neptune Dinosaur"
wrote in message
Jim et al
Thanks for that. Sorry I got a bit narky, but this was actually the first
time I ever got badly stumped by an Excel/VBA solution. I work in a very
large Govt organisation in Australia that has its reasons for de-implementing
(or not implementing) certain bits of the Office suite and VBA. I've always
suspected that there was somethiong incomplete about the VBA Help and maybe
the Object browser and some other bits; now I know ....

I now have a fully functioning neat exit from my magnificent tutorial, so
that people are able to leave their desks in a hurry and go out into the
street to vomit if they need to, so thanks again to all who pitched in.

One more thing - I presume that after the demo (or after the early exit) I
need to reset the CancelKey as follows :
Application.EnableCancelKey = xlInterrupt ?????
Is this necessary, or does VBA know to default back to this by itself?

My next Excel/VBA production will be a true Hollywood blockbuster : "Indiana
Jones Hates His Own Sequel". Free tickets to all who helped me get my start
--
Time is just the thing that keeps everything from happening all at once