Hello,

I'm working with a template file that pulls data from SAP then runs a formatting macro. I'm currently using a simple sleep timer while building the functionality of the macro. The purpose of the sleep timer is to pause the VBA code while a VBS script runs to pull data from SAP. The problem is the deviation in the time that it takes SAP to pull some data compared to pulling other data, making a sleep timer not so optimal. So I'm looking for any ideas to do a check to see if the VBS script is done pulling.

SAP exports the data into multiple excel files on my desktop, always in the same order, So I would assume that the easiest way to check if the VBS script is done would be to check if the last excel file exist yet on my desktop. I'm just not sure how to go about doing that.

Also consider, to conserve CPU usage, I would like to preform the check every 2-3 seconds.

I would also like to implement a timeout feature, so that the code doesn't get stuck in an infinite loop.

Once the file is found, I want the rest of my VBA code to run.

Any ideas or sample code would be appreciated.