>can anyone tell me how i can get the process handle for Word when i create an instance of Word ?
>i.e. i create an instance of word using this:
>
>
> obj_Word = CREATEOBJECT( "Word.Application" )
> obj_Word.VISIBLE = .T.
> ...
>
>
>and the user does some typing and editing in Word.
>(i've created a toolbar with two macro buttons, which amount to
>-- "save stuff to clipboard and quit Word" and
>-- "empty the clipboard and quit Word".
>
>back in my VFP app, i want to be able to sit there and wait for them to quit Word, at which time i will store the clipboard contents into a memo field.
>
>from a previous article here, i found i could start a process and wait for it to complete by doing the following (i'm using Adobe distiller in this example) :
>
>
>Startup_Info = long2str(68) + REPLICATE(CHR(0), 64)
>Process_Info = REPLICATE(CHR(0), 16)
>Command_String = ALLTRIM(Distiller_EXE_Spec) + ' ' + ;
> ALLTRIM(PS_PDF_Combiner_File_Spec) + CHR(0)
>Return_Code = CreateProcess(0 , Command_String , 0 , 0 , 1 , NORMAL_PRIORITY_CLASS, 0, 0, @Startup_Info, @Process_Info )
>IF Return_Code = 0
> =MESSAGEBOX("Error occurred. Error code: ", GetLastError())
> RETURN
>ENDIF
>hProcess = str2long(SUBSTR(Process_Info, 1, 4))
>DO WHILE ( .T. )
> IF ( WaitForSingleObject(hProcess, WAIT_INTERVAL) != WAIT_TIMEOUT )
> EXIT
> ELSE
> DOEVENTS
> ENDIF
>ENDDO
>Return_Code = CloseHandle (hProcess)
>
>
>
>i want to learn how to get the process hande when i start Word using the CREATEOBJECT technique as shown above.
>
>any help would sure be appreciated.
You can't use hProcess monitoring for Word, as all instances of Word share a common hProcess and the value returned is a virtual hProcess IAC. Your best bet would be to minitor the FileChange event for the target file for a file close event, to recognize that Word has released the target file. Word's Quit event isn't a really good alternative if there might be more than one instance of Word active at one time.