Option Explicit
Private Declare Function OpenProcess Lib "kernel32" _
(ByVal dwDesiredAccess As Long, _
ByVal bInheritHandle As Long, _
ByVal dwProcessId As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" _
(ByVal hObject As Long) As Long
Private Declare Function WaitForSingleObject Lib "kernel32" _
(ByVal hHandle As Long, _
ByVal dwMilliseconds As Long) As Long
Private Const SYNCHRONIZE As Long = &H100000
Private Const INFINITE As Long = &HFFFFFFFF
Private Sub Test()
Dim lPid As Long, lPhndl As Long
lPid = Shell("Calc.exe")
lPhndl = OpenProcess(SYNCHRONIZE, 0, lPid)
If lPhndl Then
Do
WaitForSingleObject lPhndl, INFINITE
CloseHandle lPhndl
Exit Do
DoEvents
Loop
End If
MsgBox "code is now resuming"
End Sub