Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
excel2002 | Setting up and Configuration of Excel | |||
Page Breaks - Excel2002 | New Users to Excel | |||
Excel2002 - use sql statements? | Excel Programming | |||
Hyperlink Excel2000 vs Excel2002 | Excel Programming | |||
VBA and comments in Excel2002 | Excel Programming |