Sign in to follow this  
Followers 0
sigil

how to detect when Excel macro has terminated?

6 posts in this topic

I'm using the ExcelCom_UDF. One of the script's actions is to run a macro in Excel; this macro takes several seconds to complete, but for various server-related issues, the length of time to run the macro varies widely, anywhere between 2 to 15 seconds usually.

Does AutoIt have a way of detecting that an Excel macro is still running? or is there an Excel function for doing so that I can call through COM?

I guess the code would look like this if there's a COM option:

$oExcel=_ExcelBookOpen($filepath)
$oExcel.run("myMacro")
while $oExcel.isRunning("myMacro")  ;or whatever the property is called
wend
rest_of_the_script()

Share this post


Link to post
Share on other sites



Does AutoIt have a way of detecting that an Excel macro is still running? or is there an Excel function for doing so that I can call through COM?

One way is to create a mutex in your excel macro and check for it in your AutoIt code. See these AutoIt and vba threads.

Share this post


Link to post
Share on other sites

Why do you bother with "$oExcel.isRunning("myMacro") ;or whatever the property is called" ?

When you execute the macro with $oExcel.run("myMacro") the control is returned to the AutoIt when the macro finishes.

So if you put a msgbox right after $oExcel.run("myMacro") that is exactly the moment the macro has terminated.

Share this post


Link to post
Share on other sites

Why do you bother with "$oExcel.isRunning("myMacro") ;or whatever the property is called" ?

When you execute the macro with $oExcel.run("myMacro") the control is returned to the AutoIt when the macro finishes.

So if you put a msgbox right after $oExcel.run("myMacro") that is exactly the moment the macro has terminated.

Actually, since posting this I found out I can't use $oExcel.run("myMacro"). I'm filling in Excel values by doing ControlClick on a button in another application that sends info from a database into an open Excel spreadsheet of a certain filename. So I need to know when the other application has finished filling in the details.

One way I was thinking I could do it is, when I click the other application, the pointer turns into a wait-signal (this application's equivalent of the hourglass) until it's finished porting the data to Excel. Is there a way that I can check to see if the wait-signal is still active?

Share this post


Link to post
Share on other sites

Now this is different.Is there any way you can check if the data has been exported by checking some values in the Excel?

What is the other application - Oracle?SAP?BO?Maybe it has its own object model?

Share this post


Link to post
Share on other sites

Now this is different.Is there any way you can check if the data has been exported by checking some values in the Excel?

What is the other application - Oracle?SAP?BO?Maybe it has its own object model?

Looks like I might have to continuously poll Excel, check to see if some cells have changed. The other application is some flavor of call center client that I haven't been able to find any support or description of an object model on the web. I think it sends requests to an oracle server on the back end somewhere, but not at a direct user interface level. the company went out of business...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0