cancel using escape key

  • Re: cancel using escape key


    Im sorry I wasn't clear enough.


    I have a script that pops up a calender when I double click any cell in colums D or E. I ant to give the user the ability to cancel the popup if he duble click by mistake. The red X is in the uper righthand corner to cancel, but my instant reaction to cancel a command is to press the esc key. That does not work. Which forces the user to move his mouse to the Red X, rather that just a simple keystroke. Therfore, my objective is to allow the unload of the popup calender by escape key.


    I hope this clears things up.


    Thanks
    Mark

  • Re: cancel using escape key


    Hi Mark,


    Do you have a CommandButton on the userform that acts as a Close/Cancel button?


    I usually have one that simply says:[vba]Private Sub CommandButton1_Click()
    Unload Me
    End Sub[/vba]Then in the Properties for the button set Cancel=True.


    HTH

  • Re: cancel using escape key


    I did have that, but the red X pretty much does the same thing. Also that still forces a mouse interaction, vs the desired keystroke.


    Thanks
    Mark

  • Re: cancel using escape key


    Quote from Bradford

    I did have that, but the red X pretty much does the same thing. Also that still forces a mouse interaction, vs the desired keystroke.


    Thanks
    Mark


    Mark, have a look @ what Richie says .... if you impliment this you will get the desired result ie Esc will unload the form.

  • Re: cancel using escape key


    Ivan, Richie & Norie,


    I wanted to try to avoid adding another button, to a popup that already has 47 buttons, 2 list boxes, and a Red X button. But if thats they way I have to do it, then I guess one more button won't hurt too much.


    Thanks very much to all of you,
    Mark

  • Re: cancel using escape key


    You can always hide the button - the user will never need to press it. However, when the user presses the escape key, Excel will act as though that button has been pressed, and carry out the unloading action.

  • Re: cancel using escape key


    Quote from Greychild

    You can always hide the button - the user will never need to press it. However, when the user presses the escape key, Excel will act as though that button has been pressed, and carry out the unloading action.


    I was going to suggest that but tested it first.


    It doesn't work.

  • Re: cancel using escape key


    Sometimes its the simple things that are overlooked. Seriously, how easy was that. LOL.


    Thanks, That works exactly the way I needed it to.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!