+ Reply to Thread
Results 1 to 4 of 4

Closing User Form

  1. #1
    Registered User
    Join Date
    03-23-2007
    Posts
    91

    Closing User Form

    Hi

    I have a userform that's called via a macro.
    How can I program the form so that when I press the ESC key it will close it and stop running the program? If I click the X on the form it closes it but I need it to work with the esc key


    thanks

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Dohko,

    The only time a UserForm processes the KeyUp, KeyDown, and KeyPress events is when there are no controls on the form to take the focus.

    Sincerely,
    Leith Ross

  3. #3
    Registered User
    Join Date
    03-23-2007
    Posts
    91
    So if there is an OK button then pressing ESC wont quit the form?

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Dohko,

    You can if the "OK" button has the focus. The button can process the keyboard input and check for "ESC". Here is an example...

    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

+ 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