#1
|
|||
|
|||
Using SendKeys in a VBA subroutine toggles NumLock
I have added a subroutine call to the context-sensitive right-click menu in Excel. For purposes of my question, I've reduced the subroutine to:
Sub Test() SendKeys("x") End Sub In this case, the subroutine simply puts an "x" in the active cell. However it inexplicably also toggles the NumLock status (from on to off or from off to on). No matter what keys are substituted for "x", NumLock is toggled. The only SendKeys statement that doesn't toggle NumLock is SendKeys(""), i.e., a null. What could be causing this bizarre behavior? |
#2
|
||||
|
||||
Don't use the parentheses:
Sendkeys "x" |
#3
|
|||
|
|||
Fixed with workaround
Removing parentheses makes no difference.
However digging further I've found this is a known problem with SendKeys. For example, see Excel VBA - make sure Numlock is always ON - Stack Overflow I've set up a clumsy workaround, so I'll move on. |
Tags |
numlock, sendkeys |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Complex Document Templates with Section Toggles and Multiple Fields | damaniam | Word | 1 | 06-04-2019 06:49 PM |
SENDKEYS with vbYesNoCancel and Select Case | kiwimtnbkr | Word VBA | 31 | 06-11-2018 04:56 AM |
Function or subroutine with counting memory | paik1002 | Word VBA | 1 | 12-15-2015 01:28 AM |
A macro that can insert FILENAME, sendkeys CTRL ALT T, paste clipboard, and nextline | kyjac85 | Word VBA | 13 | 09-20-2012 05:00 PM |
Problem with the sendkeys in Win7 | vidyapakki | Excel Programming | 1 | 05-07-2012 11:10 PM |