Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-21-2012, 02:17 AM
tinfanide tinfanide is offline Application.OnKey Numeric Plus? Windows 7 64bit Application.OnKey Numeric Plus? Office 2010 32bit
Expert
Application.OnKey Numeric Plus?
 
Join Date: Aug 2011
Posts: 312
tinfanide is on a distinguished road
Default 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?
Reply With Quote
  #2  
Old 10-22-2012, 12:05 AM
macropod's Avatar
macropod macropod is offline Application.OnKey Numeric Plus? Windows 7 64bit Application.OnKey Numeric Plus? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #3  
Old 10-22-2012, 04:39 AM
tinfanide tinfanide is offline Application.OnKey Numeric Plus? Windows 7 64bit Application.OnKey Numeric Plus? Office 2010 32bit
Expert
Application.OnKey Numeric Plus?
 
Join Date: Aug 2011
Posts: 312
tinfanide is on a distinguished road
Default

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.
Reply With Quote
  #4  
Old 11-26-2012, 03:54 AM
tinfanide tinfanide is offline Application.OnKey Numeric Plus? Windows 7 64bit Application.OnKey Numeric Plus? Office 2010 32bit
Expert
Application.OnKey Numeric Plus?
 
Join Date: Aug 2011
Posts: 312
tinfanide is on a distinguished road
Default

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
Reply With Quote
  #5  
Old 11-26-2012, 04:36 AM
macropod's Avatar
macropod macropod is offline Application.OnKey Numeric Plus? Windows 7 64bit Application.OnKey Numeric Plus? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi Tin,

The code needs to go in a normal code module, not the 'ThisWorkbook' module.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #6  
Old 11-26-2012, 06:40 AM
tinfanide tinfanide is offline Application.OnKey Numeric Plus? Windows 7 64bit Application.OnKey Numeric Plus? Office 2010 32bit
Expert
Application.OnKey Numeric Plus?
 
Join Date: Aug 2011
Posts: 312
tinfanide is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
Hi Tin,

The code needs to go in a normal code module, not the 'ThisWorkbook' module.
Yeah, ya're right, even though I don't know why.
Reply With Quote
  #7  
Old 11-26-2012, 08:41 PM
macropod's Avatar
macropod macropod is offline Application.OnKey Numeric Plus? Windows 7 64bit Application.OnKey Numeric Plus? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

I don't know why either.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Application.OnKey Numeric Plus? How to do an alpha numeric Sort By? Opul3nce Excel 1 10-15-2012 11:11 PM
Application.OnKey Numeric Plus? Sum Formula in the range with Numeric and NonNumeric data cells Spanec Excel 2 01-12-2012 09:15 AM
Application.OnKey Numeric Plus? alt+numeric doesn't work Kungen Word 3 12-02-2011 11:25 AM
Application.OnKey Numeric Plus? Convert numeric value into words KIM SOLIS Excel 5 09-12-2011 10:53 PM
Application.OnKey Numeric Plus? Validation for length and numeric type chamsy Excel 1 10-22-2010 07:31 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:47 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft