MS Excel for Mac 2011 - VB Ver 14.0 - Escape Key capture

TAPS_MikeDion

Well-known Member
Joined
Aug 14, 2009
Messages
622
Office Version
  1. 2011
Platform
  1. MacOS
Hi all,

Does anyone know if VB key capture works with Excel for Mac 2011?

I have tried several different methods to capture the ESC key being pressed and I can't seem to get it to do anything.

The last simple thing I tried was:
Application.OnKey "{ESC}", "EscapeKeyPressed"

inside the UserForm_Initialize sub,

and then just did a short:
Sub EscapeKeyPressed()
Msgbox "Escape key pressed"
End Sub


to see if that would work (unless I'm doing that wrong) and nothing happens.

Thanks.
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
It won't work while the form is active (in Windows either), if that's what you're trying to do?
 
Upvote 0
Hi Rory,

Thanks for the reply. I was trying to capture it so the user can't escape out, because hitting escape actually closes the form and jumps back to the previous form.
 
Upvote 0
Did you set a Cancel button?
 
Upvote 0
I'm not 100% sure what you mean by "setting" a Cancel button. I would call myself a VBA novice.
 
Upvote 0
Do you have a button on the form to close it, whose Cancel property is set to True? If not, pressing Esc shouldn't do anything at all.
 
Upvote 0
Oh, lol. Yes, there's a button to close and exit the form and it's Cancel property IS set to True.

I just changed it to False and now the escape key does nothing. Thanks!
 
Last edited:
Upvote 0
Have you tried writing to the QueryClose event to see if you can capture the user exiting the wrong way?
 
Upvote 0
Hi Mike,

Long time no...type. LOL

No, I'm not sure exactly how to do that.
 
Upvote 0

Forum statistics

Threads
1,214,642
Messages
6,120,698
Members
448,979
Latest member
DET4492

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top