Option Explicit
Private Const STILL_ACTIVE = &H103
Private Const PROCESS_QUERY_INFORMATION = &H400
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessID As Long) As Long
Private Declare Function GetExitCodeProcess Lib "kernel32" (ByVal hProcess As Long, lpExitCode As Long) As Long
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Public Sub LeerPuerto(Byval ExeLeerPuerto as string)
On Error GoTo Err_Sinc
Dim l1 As Long, lRc As Long
l1 = OpenProcess(PROCESS_QUERY_INFORMATION, False _
, Shell(ExeLeerPuerto, vbMinimizedNoFocus))
Do
GetExitCodeProcess l1, lRc
Sleep 100
DoEvents
Loop While lRc = STILL_ACTIVE
MsgBox "Finalizó la lectura del puerto"
Exit Sub
Err_Sinc:
MsgBox "Fallo al intentar arrancar lectura del puerto." & String(2, vbCrLf) _
& "(" & Err.Number & ") " & Err.Description, vbCritical, "Sincronizar"
End Sub