Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pause between RunCode

Status
Not open for further replies.

Klo

Technical User
Aug 28, 2002
86
US
I have a macro that runs VBA code to start a winbatch script. This script takes about 30 sec to run. Then the macro does another RunCode to start another action.
Like: RunCode Configure Patient Names
RunCode Import Patient Names

As I'm sure you have figured out the macro dosen't wait for the script to finish before running the second RunCode. The second RunCode uses the data from the first.
Any suggestions?
 
Try the following snippet of code - but you might have to tweak it/add some to it a little to fit your situation.


Option Compare Database
Dim PauseTime, Start, Finish, TotalTime

Private Sub cmdStartPause_Click()
LineA:
PauseTime = 20 ' Set duration.
Start = Timer ' Set start time.
Do While Timer < Start + PauseTime
txtChange = "Eureka"

Loop
Finish = Timer ' Set end time.
TotalTime = Finish - Start ' Calculate total time.
MsgBox "Paused for " & TotalTime & " seconds"
txtChange = "Pause end"
GoTo LineA
End Sub

where Timer is system time and 'txtChange' is a text box on a form to ensure the code works. Adjust to your situation.

Hope this helps.
 
Thanks. I'll give it a try.
 
Look up synchronous shell on Google. There are plenty of solutions out there that actually work (unlike the posted idea above. What if the batch took more than 30 seconds?)

Craig
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top