LOCAL lnChan lnChan = DDEInitiate("Word","System") IF lnChan < 0 * Word is not running THISFORM.WordWasRunning = .F. THISFORM.oWord = CreateObject("Word.Basic") ELSE DDETerminate(lnChan) THISFORM.WordWasRunning = .T. THISFORM.oWord = GetObject("Word.Basic") ENDIFNow anywhere in that form or any of its controls you can refer to THISFORM.oWord as a rerference to the word object. In the destroy of the form you can;
IF NOT THISFORM.WordWasRunning THISFORM.oWord.FileExit() ENDIF