Keystroke for Command Button

J

JJ

When I was coding in VB5 (I think), all I had to do to "assign" a
keystroke to a command button was to put an "&" before the letter in
the caption of the button. The user could then press Alt and that
letter to "press" that button without using a mouse.

For instance, if it was an "OK" button and the caption was "&OK", then
the user could press Alt+O to press the OK button. The "&" would not
be visible but the "O" would be underlined to indicate there was a
keyboard shortcut.

Is there a way to do this in VBA?

Thanks!
JJ
 
J

Jack Dahlgren MVP

It appears you can do this manually when creating a new menu item, but I
don't see anything about assigning the key using VBA.
Look at the properties for the commandbar.item and try out the likely ones.

-Jack
 
J

JJ

I found the "Accelerator" property was the one that allows you to
press Alt+<key> to create a keyboard shortcut.

Thanks!
JJ
 
J

Jack Dahlgren MVP

Good. That is a new one for me.

-Jack


I found the "Accelerator" property was the one that allows you to
press Alt+<key> to create a keyboard shortcut.

Thanks!
JJ
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top