View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Tim Williams Tim Williams is offline
external usenet poster
 
Posts: 1,588
Default 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