View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Chip Pearson Chip Pearson is offline
external usenet poster
 
Posts: 7,247
Default 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