Waiting while other program is busy
Hi There,
Thanks in advance for any help. Here is my problem:
I am running a VBA script that opens another application (using appactivate shell.......). The application creates a report and takes a varying amount of time to run. I don't want to use a delay as sometimes it runs the report quickly and other times it takes several minutes. When it becomes idle, I'd like to close it.
I could use the Shell and Wait routine but the window remains open when it has finished processing.
Is there a way that I can tell if the application is no longer busy so I can execute the code to close it(which I know how to do) and then continue on with the rest of the VBA script?
Readystate complete can be used for some things but can it be used for shelled Apps?
I've trawled the net for hours but can't seem to find any answers!
Thanks again.
Re: Waiting while other program is busy
Two questions
Inside which application is the VBA Code?
What is the application that you are trying to control?
Re: Waiting while other program is busy
Thanks Danny for the quick reply.
The VBA Code is inside Excel at the moment.
The application I'm trying to control is one we use at work. It is not a microsoft application, it is made by a third party and it is used to generate reports. It is an .exe that i run.
Re: Waiting while other program is busy
Does it have any includable references that could be used inside VBA?
Re: Waiting while other program is busy
I'm sorry, I dont know what that is. Can you give me an example?
Re: Waiting while other program is busy
An includable reference is what is know as an Object Library(DLL or TLB).. You can include these references inside your VBA Project to expose properties and methods of the program which VBA can control.
If there is nothing, then I suggest you either go back to the third party to see if they can help you with this, or you will need to look into API calls for this.
Re: Waiting while other program is busy
Ah,OK. I've tried that and there are not. I've searched for two days now for API Calls.
Do you know of an API call that can return an Applications CPU Usage (as in the task manager). I could keep checking until it retunrs to zero, that would sort me staight out.
Thanks for your help
Re: Waiting while other program is busy
You could try CloseHandle from www.allapi.net