+ Reply to Thread
Results 1 to 9 of 9

Press ECS to close userform

  1. #1
    Forum Contributor
    Join Date
    09-18-2014
    Location
    Pakistan
    MS-Off Ver
    2013, 2016
    Posts
    283

    Press ECS to close userform

    Hi Experts!

    I am developing a userform with multiple controls mostly Text Boxes and Combo Boxes etc.
    I can set KeyAscii or keycode function for each control to unload userform.
    But
    It is too lengthy and difficult to set Ascii or keycode function for every control.

    I want
    Is there any option to set this function shortly?

    I shall be very thankful for help.

    Thanks
    Amir
    Don't wait for the PERFECT MOMENT
    take the moment and make it PERFECT
    Amir

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,378

    Re: Press ECS to close userform

    Hi Amir,

    Instead of setting up shortcut keystrokes to get to all your controls on a userform, why don't you use the TAB key to move from each to the next. You can set each control's TAB ORDER and then only need to use the TAB key to get to each.

    I don't believe you can program the ESC key on a userform. I believe the ESC key is used as an escape from other problems.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Forum Contributor
    Join Date
    09-03-2015
    Location
    IE
    MS-Off Ver
    2003 - 2016
    Posts
    258

    Re: Press ECS to close userform

    As a userform cannot accept keystrokes, the easiest way to do this would be to add a CommandButton and set it's Cancel property to True.
    Last edited by grimes0332; 02-22-2016 at 01:31 PM.

  4. #4
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,645

    Re: Press ECS to close userform

    Hi there,

    See if the attached workbook does what you need - pressing the ESC key will hide the UserForm.

    It uses the following code in a standard VBA CodeModule:

    Please Login or Register  to view this content.

    And the following code in the VBA CodeModule of the UserForm:

    Please Login or Register  to view this content.
    If appropriate, you can make the Close button visible by removing the statements which change its dimensions.


    Hope this helps - please let me know how you get on.

    Regards,

    Greg M
    Attached Files Attached Files
    Last edited by Greg M; 02-22-2016 at 02:01 PM. Reason: Workbook attached

  5. #5
    Forum Contributor
    Join Date
    09-18-2014
    Location
    Pakistan
    MS-Off Ver
    2013, 2016
    Posts
    283

    Re: Press ECS to close userform

    Thanks Greg M
    Your first code shows an error.

  6. #6
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,645

    Re: Press ECS to close userform

    Hi again,

    I downloaded the workbook posted in this thread, and it works correctly on my installation.

    What sort of error are you encountering?

    Regards,

    Greg M

  7. #7
    Forum Contributor
    Join Date
    09-18-2014
    Location
    Pakistan
    MS-Off Ver
    2013, 2016
    Posts
    283

    Re: Press ECS to close userform

    I want to open that userform from another userform. While that process it shows an error.

    That thing I want to achieve.

  8. #8
    Forum Contributor
    Join Date
    09-18-2014
    Location
    Pakistan
    MS-Off Ver
    2013, 2016
    Posts
    283

    Re: Press ECS to close userform

    I want to open that userform from another userform. While that process it shows an error.

    That thing I want to achieve.

  9. #9
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,645

    Re: Press ECS to close userform

    Hi again,

    I'm sorry, but:


    I want to open that userform from another userform. While that process it shows an error.

    really doesn't describe the problem in any meaningful way

    Regards,

    Greg M

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Press ECS to close userform
    By AmirSoft in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-22-2016, 01:35 PM
  2. how to close userform using commndbutton and set automatic close at certain time
    By fatinmunie in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-23-2014, 12:51 PM
  3. [SOLVED] exit sub when press cancel button on userform
    By hcyeap in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-22-2014, 01:13 AM
  4. UserForm doesn't copy data when I press Ok
    By stojko89 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 11-11-2011, 03:31 AM
  5. excel close + save by button press. how?
    By tomro1 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-11-2006, 06:45 PM
  6. when press the close button in printpreview
    By x taol in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-04-2006, 12:45 AM
  7. trap arrow key press in userform
    By ben in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-07-2005, 01:05 PM

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