I have a
VB application that launches Word. It must then wait for the user to close Word. I can't seem to detect when Word is closed (or hang while Word is open).
I have tried getting the exit code from the OpenProcess function. When I do that Word appears to open and close immediately (if you already have one instance of word running). If you run the following code when there is already one instance of Word running, the message box fires immediately after the new instance of Word loads
Code:
Dim ProcessId&
Dim hProcess&
Dim ExitCode&
ProcessId = Shell("C:\PROGRA~1\MICROS~3\Office10\WINWORD.EXE", vbNormalFocus)
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, False, ProcessId)
Do
Call GetExitCodeProcess(hProcess, ExitCode)
DoEvents
Loop While (ExitCode = STILL_ACTIVE)
Call CloseHandle(hProcess)
MsgBox "Word was closed"
Help???
- Jerome