SendKeys Statement Doesn't Affect NUM LOCK Key StateLast reviewed: July 29, 1997Article ID: Q133327 |
The information in this article applies to:
SYMPTOMSWhen you use the SendKeys statement with the {NUMLOCK} key code in a Visual Basic, Applications Edition, procedure to send the NUM LOCK key, the NUM LOCK key state is not affected. Note that when you use the SendKeys statement to send the NUM LOCK key, while Microsoft Excel or Microsoft Project is the active application, the word NUM on the status bar is toggled (either appears or disappears). However, the NUM LOCK light on your keyboard (which indicates the state of the NUM LOCK key) does not change. The expected behavior is for the SendKeys command to turn NUM LOCK off at the start of the SendKeys command, the {NUMLOCK} key code in the SendKeys command to toggle the NUM LOCK state, and the NUM LOCK state to be restored to its original state after the SendKeys command is finished.
WORKAROUNDIn Microsoft Excel, you can use the SendKeys method to work around this behavior, as in the following example:
Sub Test() Application.SendKeys "{NUMLOCK}This is a test of the NUM LOCK key" End SubWhen you run this procedure while a worksheet is active in Microsoft Excel, NUM LOCK is turned off (if it is currently on), the NUM LOCK state in the application is toggled (although the NUM LOCK light does not change), the text is entered on the worksheet, and NUM LOCK is returned to its initial state.
STATUSMicrosoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.
MORE INFORMATIONWhen NUM LOCK is on, the numbers and mathematical symbols that appear on the numeric keypad will be entered into the worksheet when you press the keys. When NUM LOCK is off, the keypad is mapped to arrows (2,4,6,8) arithmetic functions (=,/,*,-,+,), and the function keys HOME (7), END (1), PgUp (9) , and PgDn (3).
REFERENCESFor more information about the SendKeys Statement or the SendKeys Method, choose the Search button in the Visual Basic Reference and type:
SendKeys Keywords : kbcode kbprg Version : 1.00 Platform : WINDOWS |
================================================================================
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |