+ Reply to Thread
Results 1 to 2 of 2

How to disable Esc Key

  1. #1
    Forum Contributor
    Join Date
    11-07-2005
    Posts
    280

    How to disable Esc Key

    Hi all,

    Is there any VBA code to disable Esc key when opening the workbook.

    Thank you,

  2. #2
    Valued Forum Contributor
    Join Date
    12-16-2004
    Location
    Canada, Quebec
    Posts
    363
    Hi

    This is not my code, but you can have a look at those 2 examples:
    Sub auto_open()
    Dim lCnt As Long
    Application.EnableCancelKey = xlDisabled
    For lCnt = 1 To 1000000000
    Next lCnt
    End Sub

    Sub CaptureKeyBoardInterruptExample()
    Dim X
    'Set the error handler
    On Error GoTo ReActToEvent
    'set the EnableCancelKey property
    Application.EnableCancelKey = xlErrorHandler
    'run a loop that won't stop until either esc or ctrl-break is pressed.
    While 1 = 1
    X = X
    Wend
    Exit Sub
    'control comes to this routine when either esc or ctrl-break is pressed
    ReActToEvent:

    MsgBox "Break Key Hit"
    'turn back on the interrupt property
    Application.EnableCancelKey = xlInterrupt
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1