Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 989
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 989
Default 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.
  #4   Report Post  
Posted to microsoft.public.excel.programming
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



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 989
Default 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.
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Troubles Jonas Krogh Excel Discussion (Misc queries) 1 October 22nd 09 11:14 AM
Formula troubles Excluxe Excel Discussion (Misc queries) 6 July 16th 07 04:16 PM
SUMPRODUCT troubles David Excel Worksheet Functions 2 July 9th 07 09:04 PM
COM Add-in Troubles Howard Excel Discussion (Misc queries) 0 May 22nd 07 01:59 PM
IF troubles JG Excel Worksheet Functions 6 December 24th 06 04:58 AM


All times are GMT +1. The time now is 09:42 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"