LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
tan tan is offline
external usenet poster
 
Posts: 29
Default Excel2002 & Trapping Esc key

I am on Excel 2002 and have a program that tries to trap the "Esc" key,
using
Application.EnableCancelKey = xlErrorHandler
and trapping error 18:
If Err.Number = 18 Then

The program is called from a modal form.

The problem is that if the form has ShowModal=True, the Esc key cannot be
trapped; while if the ShowModal of the form is False, then the system can
trap the Esc key.

Control Break has no problem - ie it is trappable.

Any idea on how I can have a ShowModal=True form and yet, trap the esc key?




Private Sub ExampleOfHow2HandleTheUserPressingCANCEL()
Dim iTest As Double, iCount As Double
On Error GoTo err_Sub

'xlDisabled = 0 'totally disables Esc / Ctrl-Break / Command-Period
'xlInterrupt = 1 'go to debug
'xlErrorHandler = 2 'go to error handler
'Trappable error is #18
Application.EnableCancelKey = xlErrorHandler


'<<<<<<<<<<<<<<PUT YOUR CODE HERE

exit_Sub:
On Error Resume Next
Exit Sub

err_Sub:
If Err.Number = 18 Then
If MsgBox("You have stopped the process." & vbCr & vbCr & _
"QUIT now?", vbCritical + vbYesNo + vbDefaultButton1, _
"User Interrupt Occured...") = vbNo Then
Resume 'continue on from where error occured
End If
End If

GoTo exit_Sub

End Sub



 
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
excel2002 JWD Setting up and Configuration of Excel 0 November 9th 09 03:55 PM
Page Breaks - Excel2002 Deborah New Users to Excel 2 July 4th 07 03:36 PM
Excel2002 - use sql statements? Ron Excel Programming 2 March 22nd 05 11:19 PM
Hyperlink Excel2000 vs Excel2002 Darrell Wesley[_2_] Excel Programming 5 January 11th 05 06:35 PM
VBA and comments in Excel2002 Neil Garrard Excel Programming 2 February 25th 04 12:50 PM


All times are GMT +1. The time now is 08:54 AM.

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"