1.

Solve : Batch file completion?

Answer»

Hello

OS: Windows XP
App: Access 2003 SP3

I am running a Batch file in VBA (see code below). I want to ensure the Batch file completes it's work (CREATING a TXT file) before moving onto the
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.

VBA....
  'Run external Batch file to collect documents
  Shell ("c:\BatchFile.bat"), vbMinimizedNoFocus
  'Pause VBA until Batchfile completed!
VBA....

Any help would be GRATEFULLY appreciated.

Regards
MikeThere are a COUPLE of ways to do this. This link describes one of them. I would suggest you run the shellandwait function in a loop until you receive a success return code.

Another possibility is to create a Windows Shell object in your code and use the run method to execute your batch file. Unlike the VBA shell command, the run method has a wait on return PARAMETER you can set to true.

Good luck.  Many thanks... ShellAndWait works just perfect!



Discussion

No Comment Found