LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default Toggling the NUMLOCK when using SendKeys

Try using (eg)

SendKeys "1", True

second parameter means wait until the keystrokes have been processed.

--
Tim Williams
Palo Alto, CA


"Zakynthos" wrote in message
...
I've tried, without success, to do this in a variety of ways when

attempting
to send multiple SendKey commands from Excel to an Oracle-based database
called 'Vantage Point' running in Windows.

The code I used on a UserForm1 was as follows: (it will be obvious that I
tried to adapt it from 'CAPSLOCK toggle, by the comments I left unchanged)

Private Sub UserForm_Click()

Private Sub Text1_Click()
SendKeys "1"
SendKeys "{NUMLOCK}" ' Turn on the CapsLock
SendKeys "1" ' will be printed in caps
For i = 0 To 10
SendKeys Chr(Asc("1") + i) 'will be printed in caps
Next
'DoEvents ' uncommenting this will print next line in smalls
SendKeys "o" ' will be printed in caps
SendKeys "{NUMLOCK}" ' Turn off the caps lock
SendKeys "o" ' Will be printed in smalls
End Sub


I used the following code on 'Sheet1' of my Excel workbook:

Sub inputvpco()

AppActivate "Maintain Queue Actuals"
With ThisWorkbook.Sheets("Sheet1")
SendKeys .Range("A1").Value
End With

End Sub



If the NUM LOCK is turned off, this does not turn it back on again.

I've also tried another test of this toggle using the following method
(which I'm pretty sure I followed correctly)

Start a new Standard EXE project in Visual Basic. Form1 is created by
default.
Add a CommandButton to Form1.
Copy the following code to the Code window of Form1:
Option Explicit
Private Sub Command1_Click()
SendKeys "a"
SendKeys "b"
End Sub
On the Run menu, click Start or press the F5 key to start the program.
If the NumLock light is off, turn on the NumLock light by pressing the
NumLock key. Click the CommandButton and note that the NumLock light
turns off.
Close Visual Basic and repeat the steps above; this time adding
DoEvents, as follows:
Private Sub Command1_Click()
SendKeys "a"
DoEvents
SendKeys "b"
End Sub


Again, the first half of this failed to toggle an 'on' num lock light to
off!!!!

Where do I go from here? I really do need to solve this problem of

sending
data in this way, it must be possible, and I've replicated the process

from
Excel to other non Microsoft 3rd Party programs running in Windows.



 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2007 is turning off numlock Jeff Lowenstein Excel Discussion (Misc queries) 2 February 16th 10 08:09 PM
Numlock Nakia Allen Excel Discussion (Misc queries) 1 May 29th 06 06:22 AM
How do I get the numlock + key to display a plus instead of a v? Mike Setting up and Configuration of Excel 0 August 4th 05 11:11 PM
Sendkeys will change the status of Numlock Kenneth Lam Excel Programming 5 June 4th 04 02:05 AM
Sendkeys and NumLock Key Joseph[_16_] Excel Programming 0 February 1st 04 11:15 AM


All times are GMT +1. The time now is 04:10 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"