Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Shortcut keys in forms (Excel)

Status
Not open for further replies.

ribsa3

Programmer
Jun 17, 2003
56
Hi

I would like to enable the use of shortcut keys in a userform - typically being alt-o for ok and escape for cancel. I cannot seem to find these properties as default, so I am wondering if I can employ the OnKey method in any way or if there are even simpler solutions.

I am using a third party button control so I cannot define buttons as ok or cancel buttons, so it would have to be that pressing alt-o or escape triggered a subroutine to perform the desired tasks.

Kindly,
Bjoern Sandvik



--------------------------------------------------------------------
Do what you wish, as long as it harms no one. That includes yourself.
 
Hi Bjoern....
Sandvik had great tools..... :p (hahaha)

I'm not sure if it will work... but you could try this:

Private Sub WorkBook_Open()
Application.OnKey "{set here name of shortkey}, "Execute" '(whatever name)

Sub Execute()
UserForm1.Show 'or something else of course
End Sub

Hope it'll work... ;)

Greets Jajinder
 
Yeah - pretty good tools.. Just not for VBA, obviously!

Your suggestion is not bad, nor is it optimal since declaring Application.OnKey affects the entire application. If there were a way of declaring this isolated withing a form instance, then it would be great.

Seconds?..



--------------------------------------------------------------------
Do what you wish, as long as it harms no one. That includes yourself.
 
Hi Mr. Toolman Sandvic...

Seems I was wearing the wrong goggles... :p
You just want to use shortcuts to go to the next form, but are using 3th-party-buttons. Is replacing the buttons with regular CommandButtons an option?

Greets Jajinder
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top