>oWord = createobject('Word.Application') >with oWord > .visible=.t. > .Activate >endwith > >DECLARE Sleep IN Win32API; > INTEGER nMilliseconds > >DO WHILE .T. >*!* IF CHECKWIN('Microsoft Word') >*!* = Sleep(10) && Wait a 1/100th of a second. >*!* ELSE >*!* EXIT >*!* ENDIF > If IsAppRunning( "OpusApp") && Checks if MS-Word already running > = Sleep(10) && Wait a 1/100th of a second. > ELSE > WAIT WINDOW "Exited VFP Correctly when word was closed." TIMEOUT 10 > EXIT > ENDIF >ENDDO >RELEASE oWord >RETURN > >FUNCTION CheckWin > PARAMETER tcTitle > > * Routine which sees if an application is active by looking for its > * Window title > * expC1 Window title > > DECLARE INTEGER FindWindow in Win32API as FindWindow STRING, STRING > > RETURN IIF(FindWindow(0,tcTitle)>0,.T.,.F.) > > >Function IsAppRunning > LParameters pAppClassName > > Private cClassName, cNullPointer, nRetCode > > nRetCode = 0 > cNullPointer = .Null. > cAppClassName = pAppClassName > > Declare Integer FindWindow In Win32API As CheckForWindow ; > String @cAppClassName, ; > String @nNullPointer > > nRetCode = CheckForWindow (@cAppClassName, @cNullPointer) > > Release cClassName, cNullPointer > > Return IIf (nRetCode = 0, .F., .T.) > > EndFunc >>