

InterviewSolution
Saved Bookmarks
1. |
Solve : Batch file completion? |
Answer» <html><body><p>Hello<br/><br/>OS: Windows XP<br/>App: Access 2003 SP3<br/><br/>I am running a Batch file in <a href="https://interviewquestions.tuteehub.com/tag/vba-723235" style="font-weight:bold;" target="_blank" title="Click to know more about VBA">VBA</a> (see code below). I want to ensure the Batch file completes it's work (<a href="https://interviewquestions.tuteehub.com/tag/creating-427346" style="font-weight:bold;" target="_blank" title="Click to know more about CREATING">CREATING</a> a TXT file) before moving onto the <br/>next line of VBA. I currently Loop 20 million times before moving to the next line of VBA. This is a workaround... I'm looking for a solution. <br/><br/>VBA....<br/> 'Run external Batch file to collect documents<br/> Shell ("c:\BatchFile.bat"), vbMinimizedNoFocus<br/> 'Pause VBA until Batchfile completed!<br/>VBA....<br/><br/>Any help would be <a href="https://interviewquestions.tuteehub.com/tag/gratefully-7376025" style="font-weight:bold;" target="_blank" title="Click to know more about GRATEFULLY">GRATEFULLY</a> appreciated.<br/><br/>Regards<br/>MikeThere are a <a href="https://interviewquestions.tuteehub.com/tag/couple-251182" style="font-weight:bold;" target="_blank" title="Click to know more about COUPLE">COUPLE</a> of ways to do this. This <a href="http://www.cpearson.com/excel/ShellAndWait.aspx">link</a> describes one of them. I would suggest you run the <strong>shellandwait</strong> function in a loop until you receive a <em>success</em> return code.<br/><br/>Another possibility is to create a Windows Shell object in your code and use the <strong>run</strong> method to execute your batch file. Unlike the VBA shell command, the <strong>run</strong> method has a wait on return <a href="https://interviewquestions.tuteehub.com/tag/parameter-244658" style="font-weight:bold;" target="_blank" title="Click to know more about PARAMETER">PARAMETER</a> you can set to <em>true</em>. <br/><br/>Good luck. Many thanks... ShellAndWait works just perfect!</p></body></html> | |