ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   AppActivate trouble... (https://www.excelbanter.com/excel-programming/285029-appactivate-trouble.html)

David Kay

AppActivate trouble...
 
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!

Bill Manville

AppActivate trouble...
 
David Kay wrote:
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



All times are GMT +1. The time now is 04:10 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com