I have a program that will be running 3 versions of a batch file. The parameters are passed to the batch file each time. My issue right now is that vba opens each version at once. I would like it to wait until it has completed before running the next. here is the code i currently useI found this somewhere and was wondering how to mash the two together to get vba to wait until the batch file is complete.Its not required I just want to remove some confusion. Thanks for your help.
Public Sub mPDF() Dim Loc As String Dim out As String Dim Source As String Loc = Sheets("Home").Range("H1") + "\Temp.csv" out = "G:\Shared drives\Test\Compiled" + "\Night Audit " & Format(Date - 1, "mm-dd-yyyy") & ".pdf" Source = "G:\Shared drives\Test\sejda\Excel_PRS.bat" Call Shell(Source & " " & """" & Loc & """" & " " & """" & out, vbNormalFocus) End Sub
Option Explicit Public Sub RunBatchFile() Dim strCommand As String Dim lngErrorCode As Long Dim wsh As WshShell Set wsh = New WshShell 'Run the batch file using the WshShell object strCommand = Chr(34) & _ "C:\wshshell-fun\Create New 2015 Project Folder.bat" & _ Chr(34) lngErrorCode = wsh.Run(strCommand, _ WindowStyle:=0, _ WaitOnReturn:=True) If lngErrorCode <> 0 Then MsgBox "Uh oh! Something went wrong with the batch file!" Exit Sub End If End Sub