AppActivate trouble...

  • Thread starter Thread starter David Kay
  • Start date Start date
D

David Kay

I was using AppActivate with the Sendkeys statement with
great success on my old workstation (P2-366Mhz with NT) in
a workbook I use all day to communicate with a program
running in the background. Today I got a new workstation
(P4-2Ghz with XP), loaded the workbook and the macro
doesn't work as well. The first time I try after loading
up the workbook it works and then the second time it
doesn't activate the background app (I don't know if it's
trying to send the keys). And it'll work intermittently
after that... Any help would greatly appreciated.

btw... i do have the wait option set to true...

Thanks!
 
David said:
I was using AppActivate with the Sendkeys statement with
great success on my old workstation (P2-366Mhz with NT) in
a workbook I use all day to communicate with a program
running in the background. Today I got a new workstation
(P4-2Ghz with XP), loaded the workbook and the macro
doesn't work as well.

Maybe a timing problem of some sort.

You may need to insert a DoEvents before the SendKeys to give the
AppActivate a chance to work - otherwise the keys may be being
swallowed by something else.

You may even need to insert a delay.

Here's a procedure to sleep for a while:

' at the top of your module
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

' in your code
Sleep 500 ' wait half a second

Bill Manville
MVP - Microsoft Excel, Oxford, England
No email replies please - reply in newsgroup
 
Back
Top