Z
Zakynthos
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.
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.