MrExcel Message Board

Go Back   MrExcel Message Board > Question Forums > Excel Questions

Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only.

Reply
 
Thread Tools Display Modes
Old Apr 25th, 2002, 02:45 PM   #1
Juan Pablo González
MrExcel MVP
 
Join Date: Feb 2002
Location: Bogota, Colombia
Posts: 11,927
Default

If you know (Or if you don't), you can use Control "+" to bring up the form to insert cells (Or automatically Insert Rows or Columns if you have an entire row or column selected).

Also, you can disable a shortcut key using the OnKey method, like this:

Application.OnKey "^c",""

to disable, and now, to re-enable:

Application.OnKey "^c"

I want to disable the Control "+" shortcut, I got it to work, strangely, with

Application.OnKey "^{+}",""

BUT, the problem is that this DOESN'T disable it for the "+" key in the Numeric Keyboard !! strange, isn't it ? any ideas ?
__________________
Regards,

Juan Pablo González
http://www.juanpg.com
Juan Pablo González is offline   Reply With Quote
Old Apr 26th, 2002, 06:59 AM   #2
Mark O'Brien
MrExcel MVP
 
Mark O'Brien's Avatar
 
Join Date: Feb 2002
Location: Columbus, OH, USA
Posts: 3,519
Default

Juan,

It is strange, but I seem to recall a few years ago coming across an article that told me that the mathematical operators on the number pad are mapped separately from the "main" keyboard. I wish I could find where I read that again.

One observation that I'll make though is that the /*+- all still work when Num Lock is off and that 12369874 act as the cursor keys etc.

Another thing I found in the help file, and I'm sure you did too is that the Sendkeys/Onkey function {ENTER} is actually the number pad ENTER and not the main keyboard ENTER, which is tilde (~).

If you find a solution please post it because this is going to bug me until it's solved. (I'll continue to look at it as well) I'm pretty sure we wont have to use any "Hook" API's.
Mark O'Brien is offline   Reply With Quote
Old Apr 26th, 2002, 07:34 AM   #3
Mark O'Brien
MrExcel MVP
 
Mark O'Brien's Avatar
 
Join Date: Feb 2002
Location: Columbus, OH, USA
Posts: 3,519
Default

It appears that this is a well known limitation to the OnKey and SendKeys functions. I've been through the google archives and even looked up some stuff on key mapping.
__________________
Mark O'Brien

Columbus Ohio Celtic Supporters Club
Mark O'Brien is offline   Reply With Quote
Old Apr 26th, 2002, 11:30 PM   #4
Colo
MrExcel MVP
 
Colo's Avatar
 
Join Date: Mar 2002
Location: Kobe, Japan
Posts: 1,420
Default

Hi. Just information.
When I want to know keycode, use following.

On Userform:

Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)"
" MsgBox ""KeyCode isF"" & KeyCode"
End Sub

The key code of + key the Numeric Keyboard is 107.

Sub Enable()
Application.OnKey "^{107}", "Test1"
End Sub

Sub Disable()
Application.OnKey "^{107}", ""
End Sub

Sub Test1()
MsgBox "it works"
End Sub

__________________
Regards,

Masaru Kaji aka Colo - Ex Microsoft MVP Since 2004 -2009
Colo is offline   Reply With Quote
Old Apr 26th, 2002, 11:48 PM   #5
Juan Pablo González
MrExcel MVP
 
Join Date: Feb 2002
Location: Bogota, Colombia
Posts: 11,927
Default

Thanks a lot Colo

I was trying with something like that, but, was using another event. Thanks, I really appreciate it !
__________________
Regards,

Juan Pablo González
http://www.juanpg.com
Juan Pablo González is offline   Reply With Quote
Old Apr 27th, 2002, 01:54 AM   #6
Mark O'Brien
MrExcel MVP
 
Mark O'Brien's Avatar
 
Join Date: Feb 2002
Location: Columbus, OH, USA
Posts: 3,519
Default

Nice work Colo!!!

I spent about an hour trawling through the microsoft forum and no one could answer this.

I was reading about key mapping and apparently the "official" line from MS for not have this explicitly in VBA is because this keycode for the Keypad plus sign could change depending upon the local settings. I recall seeing 107, but didn't know you could use it in this way. I also recall a number in the 70's being used as well, but this may be a UNIX thing. (Besides, all three of us are using different settings I'm guessing, US, Japan and Colombia.)

Well done again Colo.
__________________
Mark O'Brien

Columbus Ohio Celtic Supporters Club
Mark O'Brien is offline   Reply With Quote
Old Apr 27th, 2002, 11:03 AM   #7
Juan Pablo González
MrExcel MVP
 
Join Date: Feb 2002
Location: Bogota, Colombia
Posts: 11,927
Default

Just one more thing. After experimenting a little with this, I found out what was pretty obvious, just wanted to make it clear for everyone.

With NumLock off, the "7" key in the Numeric keyboard, wich acts as Home, has a KeyCode of 36, but with NumLock on, it has a KeyCode of 103.

Another thing, NumLock's KeyCode is 144, but, I couldn't have it to react with the OnKey (I don't need to, but, I wanted to experiment with this possibility !)

Nothing else for now. Thanks again Colo. I was using the KeyPress wich uses a KeyAscii parameter.
__________________
Regards,

Juan Pablo González
http://www.juanpg.com
Juan Pablo González is offline   Reply With Quote
Old Apr 27th, 2002, 07:51 PM   #8
Colo
MrExcel MVP
 
Colo's Avatar
 
Join Date: Mar 2002
Location: Kobe, Japan
Posts: 1,420
Default

Hi Juan and Mark. This time I just knew it.
Useally I am using Note type PC which has no numeric keyboard.
So, I don't know about keycode of "numeric keyboard" more than this.

But about "Application.OnKey", I have just one more information for everyone.
If need to use "ByVal or ByRef" we can use Chr(charcode) like following.
(Sorry I don't know what do I call it in English:I wish someone will help me.)

Pls Try.
Ctrl + UP or Down or Left or Right :Make Activecell.Interior.Color Red
Ctrl + Shift + UP or Down or Left or Right :Make Activecell.Interior.Color None


'----------------------------------------------------------------------
Option Explicit

Dim MyKey, cnt As Integer

Private Sub MyKeySet()
MyKey = Array("^{UP}", "^{DOWN}", "^{LEFT}", "^{RIGHT}", _
"+^{UP}", "+^{DOWN}", "+^{LEFT}", "+^{RIGHT}")
End Sub

Sub Enable()
Dim Val1, Val2, Val3
Call MyKeySet

Val1 = Array(-1, 1, 0, 0, -1, 1, 0, 0) '1st
Val2 = Array(0, 0, -1, 1, 0, 0, -1, 1) '2nd
Val3 = Array(True, True, True, True, False, False, False, False) '3rd

For cnt = LBound(MyKey) To UBound(MyKey)
Application.OnKey MyKey(cnt), "'MICI" & _
Chr$(34) & Val1(cnt) & Chr$(34) & "," & _
Chr$(34) & Val2(cnt) & Chr$(34) & "," & _
Chr$(34) & Val3(cnt) & Chr$(34) & "'"
Next
End Sub

Sub Disable()
Call MyKeySet
For cnt = LBound(MyKey) To UBound(MyKey)
Application.OnKey MyKey(cnt)
Next
End Sub

Sub MICI(RowOffset As Integer, ColumnOffset As Integer, flg As Boolean)
Dim lngColorIndex As Long
With ActiveCell
Select Case flg
Case True
lngColorIndex = 3
Case Else
lngColorIndex = xlNone
End Select
.Interior.ColorIndex = lngColorIndex
.Offset(RowOffset, ColumnOffset).Select
End With
End Sub
'----------------------------------------------------------------------

_________________
With regards,
Colo



[ This Message was edited by: Colo on 2002-04-27 18:52 ]
Colo is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 02:49 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
All contents Copyright 1998-2012 by MrExcel Consulting.
diabetic desserts recipes recipes Diabetic Soups Holiday Pizza Recipes Popcorn Recipes Recipes For Microwave Pasta Recipes Casserole Recipes Chili Recipes Curry Recipes Crockpot Recipes Apples Recipes Bread Recipes Vegetarian Recipes Vegetable recipes Desserts Recipes Appetizers Ethnic Recipes Meat Dishes Barbecue Recipes Sauces Recipes Marinade Recipes Low Fat Recipes Frugal Gourmet Kitchen Classics Recipes On The Grill Cook Books Seafood Recipes Cajun Recipes Breads Low Fat Low Fat Breads Bread Machine Recipes Yeast Breads Quick Breads Fat Free Vegetarian Salad Recipes Eggplant Recipes Radish Recipes Tomato Recipes Jalapeno Recipes Potato Recipes Lettuce Recipes Cabbage Recipes Beans Ambrosia Recipes Biscotti Recipes Desserts Low Fat Cookie Recipes Cheesecake Recipes Cake Recipes Pie Recipes Muffin Recipes Custard Recipes Best Appetizers Appetizers Low Fat Salsa Recipes Dip Recipes International Recipes Afghan Recipes Alaska Recipes French Recipes German Recipes Greek Recipes Italian Recipes Spanish Recipes Thai Recipes Korean Recipes Chinese Recipes Mexican Recipes Indian Recipes Beef Recipes Pork Pork & Ham Pork Butts Pork Chop Recipes Pork Ribs Rulled Pork Poultry Recipes Stews Recipes Ground Beef Barbecue Grill Barbecue Smoker All Purpose Sauce BBQ Sauce Barbecue Sauce Carolina BBQ Sauce Pickle Recipes Marinades Smoking Low Fat Appetizers & Dips Low Fat Breakfast Low Fat Cakes Low Fat Cheesecakes Low Fat Cookies Low Fat Desserts Low Fat Fish & Seafood Low Fat Meats Low Fat Pasta Low Fat Pies Low Fat Salads Low Fat Sandwiches Low Fat Sauces & Condiments Low Fat Sides Low Fat Soups Low Fat Vegetarian Baker's Dozen Taste of Home Recipe Book Bon Appetit Cookbook Blacktie Cookbook Buster Cook Book Cookbook USA Cook Book Cook Book Sara's Cookbook Sara's Cookbook Appetizers and Dips Poultry recipes Diabetic recipes Holiday recipes Miscellaneous recipes 110 recipes 1986 Usenet cookbook 2900 recipes Cyberrealm recipes Great sysops of world Specialty recipes Ceideburg recipes Cheese recipes Chili recipes Fruits recipes Garlic recipes Great chefs of NY Londontowne recipes Raisins recipes Recipes for kids US Food Vegetarian recipes Bread recipes Drinks Meat Dishes Brisket recipes Caribou recipes Chicken recipes Filet mignons recipes Pork recipes Swordfish recipes Turkey recipes Pasta recipes Uncategorized recipes Ethnic recipes Canada recipes English recipes Ethiopia recipes Germany recipes Greece recipes Mexican recipes Philippines recipes Welsh recipes Microwave recipes Soups recipes Vegetable recipes Asparagus recipes Barley recipes Brown rice recipes Lentil recipes Mushrooms recipes Salads recipes Wild rice Desserts recipes Cakes recipes Chocolate recipes Cookies recipes Ice cream recipes