LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,549
Default Control-Break

In VBA Help, type in EnableCancelKey.
You can also find it as a property of the Application object.

Escape/ControlBreak generates Err.Number 18.
You can trap for that in your error handler if you set EnableCancelKey to xlErrorHandler.
It is then up to you to write whatever code you need when that error occurs...
'--
Exit Sub
ErrorHandler:
If Err.Number < 18 then
'Do something to handle error
Else
'Do something to make your impatient user happy
End If
--
Jim Cone
Portland, Oregon USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)



"Neptune Dinosaur"
wrote in message
Hmmmm

Application.EnableCancelKey turns OFF the response to Control-Break. VBA
help does not return any remotely relevant hits when I type in keywords like
"Enable" or "CancelKey" or anything relevant to the issue. Where should I be
looking?
--
Time is just the thing that keeps everything from happening all at once


"Jim Cone" wrote:


Application.EnableCancelKey is what you are looking for.
Check the help file for details.
If you run any lengthy loops, make sure to put a DoEvents function
in there someplace.
--
Jim Cone
Portland, Oregon USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)




"Neptune Dinosaur"

wrote in message
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

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
blank row after control break GregNga Excel Discussion (Misc queries) 3 September 6th 07 02:55 PM
Cannot Control - Break out of VBA vmegha Excel Discussion (Misc queries) 1 December 22nd 05 02:44 PM
Control Break in Excel Kees Boer Excel Programming 2 August 12th 05 02:36 AM
Prevent control & break N10 Excel Programming 2 September 29th 04 10:32 AM
Control & Break Alan.Hutchins Excel Programming 3 July 27th 04 04:23 PM


All times are GMT +1. The time now is 05:35 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"