lncount = 0 DO WHILE lncount < 4 IF checkit() WAIT WINDOW "Close Word to continue" NOWAIT oWord = createobject('Word.Application') with oWord .visible=.t. .Activate ENDWITH ENDIF lncount = lncount+1 ENDDO RETURN FUNCTION checkit *-------- ------------ DECLARE Sleep IN Win32API; INTEGER nMilliseconds DO WHILE .T. If IsAppRunning( "OpusApp") && Checks if MS-Word already running = Sleep(10) && Wait a 1/100th of a second. ELSE WAIT WINDOW "Word was just closed." TIMEOUT 10 EXIT ENDIF ENDDO RELEASE oWord CLEAR DLLS "sleep" RETURN .T. 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>I am opening and closing word very quickly and sometimes I get an error: