ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   troubles with SendKeys (https://www.excelbanter.com/excel-programming/335914-troubles-sendkeys.html)

Mark

troubles with SendKeys
 
Hello,

I've been having trouble getting SendKeys to act as I would like.

The thing I started to work on is to load data to another application, but I
simplified it down to this, and it still stops:

****************
For i = 1 To 6 Step 1

AppActivate "Untitled - Notepad", True
DoEvents
sendkeys "123456{ENTER}"
DoEvents

Next i
************

When I run that, it starts Notepad, but doesn't enter anything. The code
doesn't stop though... each time that I click on the Excel application
window, or on the VBA code window, if I'm running it that way, it cycles one
more loop through the code, entering the data into Notepad, as it should.

But it only ever does one iteration of the loop at a time, waiting for me to
click on the application window again before it continues.

Ideas as to why?

Thanks,
Mark

Chip Pearson

troubles with SendKeys
 
I would avoid SendKeys at all costs. Instead of opening Notepad
and trying to write data to it, why don't you just create a text
file and use direct i/o on the file?

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"mark" wrote in message
...
Hello,

I've been having trouble getting SendKeys to act as I would
like.

The thing I started to work on is to load data to another
application, but I
simplified it down to this, and it still stops:

****************
For i = 1 To 6 Step 1

AppActivate "Untitled - Notepad", True
DoEvents
sendkeys "123456{ENTER}"
DoEvents

Next i
************

When I run that, it starts Notepad, but doesn't enter anything.
The code
doesn't stop though... each time that I click on the Excel
application
window, or on the VBA code window, if I'm running it that way,
it cycles one
more loop through the code, entering the data into Notepad, as
it should.

But it only ever does one iteration of the loop at a time,
waiting for me to
click on the application window again before it continues.

Ideas as to why?

Thanks,
Mark




Mark

troubles with SendKeys
 
I would avoid SendKeys at all costs

Yeah, that's my opinion of it, too, but there have been occasions when I got
it to work better than this, before.

Instead of opening Notepad and trying to write data to it, why don't you just create a text file and use direct i/o on the file?


I would very happily do that, if a text file had been what I had originally
needed to do with it. The Notepad screen was only an attempt to find out
where the problme was.. in the destination application, or in the VBA code.
The intended use had nothing to do with Notepad, or a regular text file.

The intended use was to enter some data through a user interface in an
Oracle Applications window... Yes, data can sometimes be entered directly
into tables there, too, but only if they give you an interface, and I'm not
in on that.

The specific thing I was working on doing was to load a list of
combinations... in this case, 33 of them. The method recommended by Oracle
consultant is to cut/paste/down arrow through the list, entering them into
the screen.

This time, it's 33.. but I already did that 33 twice, and it won't always be
the same thing.

So, I was building a little data loader ... (yep, data loaders are available
for sale, too).

But anyway, I agree Chip, SendKeys is trash, and if I could just use i/o on
a text file, I would. Notepad was only testing to prove the problem was in
SendKeys, though.

Thanks.

Tim Williams

troubles with SendKeys
 


AppActivate "Untitled - Notepad"
DoEvents

For n = 1 To 10
SendKeys "Hello " & n & "{ENTER}"
DoEvents
Next n



works for me
Tim

--
Tim Williams
Palo Alto, CA


"mark" wrote in message
...
Hello,

I've been having trouble getting SendKeys to act as I would like.

The thing I started to work on is to load data to another application, but

I
simplified it down to this, and it still stops:

****************
For i = 1 To 6 Step 1

AppActivate "Untitled - Notepad", True
DoEvents
sendkeys "123456{ENTER}"
DoEvents

Next i
************

When I run that, it starts Notepad, but doesn't enter anything. The code
doesn't stop though... each time that I click on the Excel application
window, or on the VBA code window, if I'm running it that way, it cycles

one
more loop through the code, entering the data into Notepad, as it should.

But it only ever does one iteration of the loop at a time, waiting for me

to
click on the application window again before it continues.

Ideas as to why?

Thanks,
Mark




Mark

troubles with SendKeys
 
Yep, I know it's suposed to work, and as I mentioned, I've gotten it to work
better in the past.

But not today... was taking the naps in the middle that I mentioned...
needing prodded along.

Thanks for looking, though.


All times are GMT +1. The time now is 11:12 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com