PDA

View Full Version : Exit, allow time for external app to run, and come back to a VBA sub



leo
03-01-2014, 05:39 PM
Hi guys. I have been struggling to find a code that would allow me to exit my Sub and then return to the same line after a few seconds. Is that possible?

Bob Phillips
03-02-2014, 06:14 AM
You could put a Wait in there.

leo
03-02-2014, 06:27 AM
You could put a Wait in there.

I tried wait, sleep and other similar techniques but none actually exit the sub. They just pause. The app I need to run won't start until I exit the sub and I call it through an excel formula. Is there a way to actually exit the sub, wait, and then come back to the same line?

Bob Phillips
03-02-2014, 07:40 AM
How about adding DoEvents, that should give the other app a chance to grab some OS resources, then wait. What is the other app?

leo
03-02-2014, 02:26 PM
How about adding DoEvents, that should give the other app a chance to grab some OS resources, then wait. What is the other app?
I did try Do while, trying to get the loop repeating until my variable gets computed in the external app, but that never happens. My external app is Bloomberg. The Bloomberg excel add ins only run when there is no vba sub running. So as I need to download details of bonds, through .formulA expressions that use bbg add ins in excel, I actually need to exit the routine for those formulas to work. Is there a way to exit one sub and run another one? That would work. I could create a dummy sub whose only purpose is to stop and restart the main one. But I haven't been able to do this as there's always one sub running. Thx so much for trying to answer so far. Let me know if you can think of any solution.