Jump to content

Recommended Posts

Posted

Hello everybody,

I am using excel and perform a number of macros there. However, performing the macros sometimes takes a couple of minutes.

Is there an elegant way of waiting for the macro to be complete until AutoIt performs the next action?

I have thought about the following possible solutions, but none of the seems quite satisfying:

- simply using Sleep() and waiting for a really long time

- monitoring the mouse cursor. Problem ist, that it's sometimes flickering between the different status symbols...

- including a line at the end of the macro, which writes a certain content into a defined cell. Once AutoIt can read the content, the macro must be done. But what does Autoit read while excel is still calculating? Isn't this slowing down the system even more?

If anyone here has experience with this, I hope you share it.

Thank y'all very much.

Christoph

Posted

How do you run the macro in AutoIt?

If you do something like:

$oExcel = ObjCreate("Excel.Application") ;crete excel object

$oExcel.WorkBooks.Open($FileName) ;open desired file containing the macro

$oExcel.Run("Macro1") ;run the macro

"more code"

It will do the "more code" right after the macro completes, wich would solve your issue.

Posted

i had this problem before too.. the macro completes, but if the macro enters some numbers into some cells, excel still needs to calculate that. Never found a good solution aside from sleep..

this:

- including a line at the end of the macro, which writes a certain content into a defined cell. Once AutoIt can read the content, the macro must be done. But what does Autoit read while excel is still calculating? Isn't this slowing down the system even more?

might be the best solution.. just put a sleep in there so autoit isn't checking the cell every millisecond.

Posted

Hey Juvigy,

thanks for the help. It works perfectly with

$oExcel.Run("Macro1")

@all: Remember: If you are using non-English-Versions of Excel, Macro, might acutally be spelled Makro. If you want to spare yourself the high blood pressure. Change it right away ! :)

@cageman: Yes, I think it would actually work. But as describes above, it's just so much nicer!!

Thanks a lot

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...