I do not take credit for this code. It was found somewhere on this site.
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long
Private Const SYNCHRONIZE = &H100000
Private Const INFINITE = -1&
Dim sPrgm As String
Dim lProcID As Long
Dim hProc As Long
Public Sub RunUntilFinished(ByVal sApp As String)
' Start the App
On Error GoTo ErrHndlr
lProcID = Shell(**NAME OF PROCCESS TO SHELL**, vbHide)
On Error GoTo 0
DoEvents
' Wait for the App
hProc = OpenProcess(SYNCHRONIZE, 0, lProcID)
If hProc <> 0 Then
WaitForSingleObject hProc, INFINITE
CloseHandle hProc
End If
Exit Sub
ErrHndlr:
MsgBox "Error starting App:" & vbCrLf & _
"App: " & sApp & vbCrLf & _
"Err Desc: " & Err.Description
Err.Clear
End Sub Swi