Word is running?

U

Unregistered

Guest
The following code uses com-handles to try and connect to Word. If it connects to a running instance of Word then hWord has a valid-handle. If hWord = ? then it means it could not connect to a running instance of Word.


DEFINE VARIABLE hWord AS COM-HANDLE NO-UNDO.

CREATE "Word.Application" hWord CONNECT NO-ERROR.

IF NOT VALID-HANDLE(hWord) THEN
MESSAGE "Word not running.".
ELSE
MESSAGE "Word is running.".

RELEASE OBJECT hWord NO-ERROR.



You could then add the following code to run Word and make it visible.

CREATE "Word.Application" hWord NO-ERROR.
hWord:VISIBLE = TRUE.
 
Top