troubles with SendKeys

G

Guest

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
 
C

Chip Pearson

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
 
G

Guest

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.
 
T

Tim Williams

AppActivate "Untitled - Notepad"
DoEvents

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



works for me
Tim
 
G

Guest

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top