Jump to content
Macro Express Forums

Waiting For Excel Recalculation


Recommended Posts

Although very new to this program, I am finding it quite fantastic and the opportunities for its use seem endless.


I am wanting to use ME to; open an Excel spreadsheet, run recalculation then save the result, rename, and send email. All is fine except the Excel recalculation can vary in the time (1 to 5 minutes) it takes to finish, so ME can sometimes start the next step before the Excel recalc has finished.


I have tried "wait until file is ready" although I suspect this is not the correct method especially as it doesn't work. I wasn't too keen on setting the waiting time as a set period, as I would have to set this for too long to be sure.


Any suggestions and/or advice very much appreciated.


Thanks in advance.

Link to comment
Share on other sites

Is there something that gives you a visual clue that the recalculation is occurring? For example, is there another Window that comes up, does the title bar change, does the mouse pointer change, or is there a specific area of the screen that changes color? There are macro commands to detect these types of events:

// Another Window
If Window Title "Recalulating" is running
End If

// Titlebar change
Variable Set String %T1% from Window Title
If Variable %T1% contains "Recalulating"
End If

// Mouse pointer change
Wait for Mouse Cursor: Arrow

// Color on screen changes
Get Pixel: Window Coords: 100,200 into %N1%
If Variable %N1% = 15836021

I would try the Wait for Mouse Cursor command first. For the other techniques you will need to use a Repeat loop. Something like this:

Variable Set String %T2% ""
Repeat Until %T2% = "DONE"
 If Window Title "Recalulating" is running
   Variable Set String %T2% "DONE"
 End If
 Delay 0.25 Seconds
Repeat End

You may also be able to use the Wait Window Lose Focus command like this:

If Window Title "Recalulating" is running
 Wait Window Lose Focus: "Recalculate"
End If

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...