View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips Bob Phillips is offline
external usenet poster
 
Posts: 10,593
Default working hotkey even if any control has focus in userform

Add a button to the form, and code like so

Private cmdEsc_Click()
Unload Me
End Sub

and set the Cancel property of that button to True

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"x taol" wrote in message
...


i want to close the userform if press the esc key.
Current, the userform have many controls.

in that case, even if any control has focus, i want to close the
userform when the esc key pressed.

*** Sent via Developersdex http://www.developersdex.com ***