I am writing VBA code in a Word document running Word 2007 in Windows 7.
I would like to let a user use a keyboard shortcut to run a macro named “Exercice1” by using:
Shift + Alt + 1 on the numeric keypad.
The usual way to assign a keyboard shortcut in VBA is with this kind of code:
yShift, wdKeyAlt, wdKey1)
The second line of that code names the macro and the last line assigns the shortcut key combination.
My problem is what word to use to indicate number 1 on the numeric keypad. The code above successfully assigns the combination Shift + Alt + 1 (at the top of the keyboard) to the “Exercice1” macro.
I have attached a list of keyboard constants that usually work, but not always. It says that the constant for the numeric keypad 1 is “wdKeyNumeric1”. That does not work in the above code.
If I assign a keyboard shortcut manually using OfficeKey > Word Options > Customize > Customize Keyboard Shortcuts > Macros etc. and press Shift + Alt + 1 on the numeric keyboard, it assigns the shortcut to
“Alt + End”.
That works, but those are not the VBA code words to use.
“wdKeyEnd” also does not work.
I guess my chart of keyboard constants does not work, but where can I find a better chart of keyboard constants?
Thanks for any help!
John Robin (Allen)