ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   working hotkey even if any control has focus in userform (https://www.excelbanter.com/excel-programming/375692-working-hotkey-even-if-any-control-has-focus-userform.html)

x taol

working hotkey even if any control has focus in userform
 


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 ***

Bob Phillips

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 ***




x taol

working hotkey even if any control has focus in userform
 

thanks bob.
then, I will automate your source code.

Private cmdEsc_Click()
Unload Me
End Sub

my source code follow.
with me.controls.add("forms.commandbutton.1")
Left = 10
Top = 10
Width = 0
Height = 0
Cancel = True
End With
and then i don't know

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

Bob Phillips

working hotkey even if any control has focus in userform
 
Don't add the button dynamically, add it at design.

--
HTH

Bob Phillips

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

"x taol" wrote in message
...

thanks bob.
then, I will automate your source code.

Private cmdEsc_Click()
Unload Me
End Sub

my source code follow.
with me.controls.add("forms.commandbutton.1")
Left = 10
Top = 10
Width = 0
Height = 0
Cancel = True
End With
and then i don't know

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





All times are GMT +1. The time now is 01:15 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com