Recognizing when an Excel Macro has finished.

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
cabramson
Newbie
Posts: 6
Joined: Wed Jul 04, 2007 5:56 pm
Location: Cypress, CA

Recognizing when an Excel Macro has finished.

Post by cabramson » Wed Jul 04, 2007 7:50 pm

I use a program named ShowCase (SPSS) to query data from our AS/400 and return it to an Excel workbook. After the data is returned, it triggers a macro refreshing all the PivotTables in the workbook.

The script now correctly starts the workbook, chooses to Refresh the Data, logs into ShowCase server, logs into the ODBC connection, and returns the data to Excel. The status bar changes from Running Showcase query, to Restoring Data, to Ready.

I've been trying to find the right way to recognize that control has passed back to Excel without looking for a change in the screen image; but, I'm not getting it right.

I've tried using SetFocus with WaitReady>1; but, the script is not finishing; so, I must be missing something.

Can someone point me in the right direction?

Thanks.

Carl





[/code]

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Wed Jul 04, 2007 9:21 pm

I would use WaitScreenImage
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

cabramson
Newbie
Posts: 6
Joined: Wed Jul 04, 2007 5:56 pm
Location: Cypress, CA

Post by cabramson » Wed Jul 04, 2007 11:10 pm

That worked. Thanks.

I created and ran a separate script to get the screen image file.

If I need to make this portable across users with different screen resolutions, I guess I'd need to capture at each resolution or is there a better way?

Take care,

Carl

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Thu Jul 05, 2007 6:57 am

First, there's no need to write a separate script to capture the screen image. Just use the image capture tool. In the editor select Tools/Image Capture Tool or if using the command builder you will see a capture button on the WaitScreenImage dialog.

Second, there's no need to use the entire screen. I would simply capture the area of the status bar that signifies process completion - or whatever part of the screen tells me the process is complete. This can then be used regardless of window size or placemenet and regardless of screen dimensions. But if the color depth varies between systems, yes, you may need to capture the graphic on each target system.

For examples see:
http://www.mjtnet.com/imagerecognition.htm
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts