ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Assign Keybindings to a Userform (https://www.excelbanter.com/excel-programming/389514-assign-keybindings-userform.html)

PaulW

Assign Keybindings to a Userform
 
I'm making a calculator type userform. It will be easier to use that for
someone to find a calculator, and will have additional options for inserting
values into the active sheet.

I've made the *current* buttons on the userform look exactly like the
numberpad on my keyboard, without the pgup, home, del, etc, just the numbers
and such.

What I'd like to do is let people simply use the numberpad on their keyboard
to "activate" the buttons on the userform, like 4, or +

I tried an
Application.OnKey "7","Command7_Click"
in the userform initialisation, but that didn't work, it threw up an error.
So I'm assuming that I can't link to a userform macro or something?
I also tried to use the "Accelerator" field, but that only works when Alt is
pressed down. And only works on the keyboard section, rather than the
numberpad. So I have one 7 that works when I press shift, but one that
doesn't.

Is there a quick way to assign the numberpad keys (including numlock) to
buttons on a userform? Since they're command buttons, it doesn't need to
press the button as such, just trigger the "commandbutton_click" event.

[email protected]

Assign Keybindings to a Userform
 
On 16 May, 16:44, PaulW wrote:
I'm making a calculator type userform. It will be easier to use that for
someone to find a calculator, and will have additional options for inserting
values into the active sheet.

I've made the *current* buttons on the userform look exactly like the
numberpad on my keyboard, without the pgup, home, del, etc, just the numbers
and such.

What I'd like to do is let people simply use the numberpad on their keyboard
to "activate" the buttons on the userform, like 4, or +

Wouldn't the keypress event of the form do it for you - can't check at
the moment as the PC is tied up with a long macro job, but I would
check that first!

I tried an
Application.OnKey "7","Command7_Click"
in the userform initialisation, but that didn't work, it threw up an error.
So I'm assuming that I can't link to a userform macro or something?
I also tried to use the "Accelerator" field, but that only works when Alt is
pressed down. And only works on the keyboard section, rather than the
numberpad. So I have one 7 that works when I press shift, but one that
doesn't.

Is there a quick way to assign the numberpad keys (including numlock) to
buttons on a userform? Since they're command buttons, it doesn't need to
press the button as such, just trigger the "commandbutton_click" event.





All times are GMT +1. The time now is 02:12 AM.

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