#1
|
|||
|
|||
Application.OnKey Numeric Plus?
I went to this site and didn't find the keycodes for "Numeric Plus" for Application.OnKey:
http://msdn.microsoft.com/en-us/libr...ice.11%29.aspx Somebody said it should be "{ADD}", but when I wrote it, it ran and said "error". If {+}, it's not the Numeric Plus. It's the Plus sign instead. Please help. What is the code for the Numeric Plus? |
#2
|
||||
|
||||
As you can see from the link, there is no {ADD} argument for OnKey. That's because there's no ADD key. However, you can use:
Code:
Sub ReAssignKeypad() Application.OnKey "{096}", "KeyPad0" Application.OnKey "{097}", "KeyPad1" Application.OnKey "{098}", "KeyPad2" Application.OnKey "{099}", "KeyPad3" Application.OnKey "{100}", "KeyPad5" Application.OnKey "{101}", "KeyPad5" Application.OnKey "{102}", "KeyPad6" Application.OnKey "{103}", "KeyPad7" Application.OnKey "{104}", "KeyPad8" Application.OnKey "{105}", "KeyPad9" Application.OnKey "{106}", "KeyPadMult" Application.OnKey "{107}", "KeyPadPlus" Application.OnKey "{109}", "KeyPadMinus" Application.OnKey "{110}", "KeyPadPoint" Application.OnKey "{111}", "KeyPadDiv" End Sub Sub KeyPad0() MsgBox "You pressed: 0" End Sub Sub KeyPad1() MsgBox "You pressed: 1" End Sub Sub KeyPad2() MsgBox "You pressed: 2" End Sub Sub KeyPad3() MsgBox "You pressed: 3" End Sub Sub KeyPad4() MsgBox "You pressed: 4" End Sub Sub KeyPad5() MsgBox "You pressed: 5" End Sub Sub KeyPad6() MsgBox "You pressed: 6" End Sub Sub KeyPad7() MsgBox "You pressed: 7" End Sub Sub KeyPad8() MsgBox "You pressed: 8" End Sub Sub KeyPad9() MsgBox "You pressed: 9" End Sub Sub KeyPadMult() MsgBox "You pressed: *" End Sub Sub KeyPadPlus() MsgBox "You pressed: +" End Sub Sub KeyPadMinus() MsgBox "You pressed: -" End Sub Sub KeyPadPoint() MsgBox "You pressed: ." End Sub Sub KeyPadDiv() MsgBox "You pressed: /" End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
Yes, I now know from your example. Previously I was wondering if I could use the ASCII (that's the number you've listed above) and just didn't know how to use it in VBA. But learn how to do it from your example. Really thank you for this.
Last edited by macropod; 10-22-2012 at 05:31 AM. Reason: Deleted unnecessary quote of entire previous post. |
#4
|
|||
|
|||
Dear macropod,
I don't know why later on I run the codes and the error comes: "Cannot run the macro [macro name]. The macro may not be available in the workbook or all macros may be disabled." Book2.xlsm Tin |
#5
|
||||
|
||||
Hi Tin,
The code needs to go in a normal code module, not the 'ThisWorkbook' module.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#6
|
|||
|
|||
Yeah, ya're right, even though I don't know why.
|
#7
|
||||
|
||||
I don't know why either.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to do an alpha numeric Sort By? | Opul3nce | Excel | 1 | 10-15-2012 11:11 PM |
Sum Formula in the range with Numeric and NonNumeric data cells | Spanec | Excel | 2 | 01-12-2012 09:15 AM |
alt+numeric doesn't work | Kungen | Word | 3 | 12-02-2011 11:25 AM |
Convert numeric value into words | KIM SOLIS | Excel | 5 | 09-12-2011 10:53 PM |
Validation for length and numeric type | chamsy | Excel | 1 | 10-22-2010 07:31 AM |