Dear Cetin,
That did it. Thanx again. Are you ever in New York? Next time you are, my son and I would like to take you out for the best meal in town. Don't hesitate to contact us at
dadigidoc@aol.com or
dittozip@aol.com or
drgorin@mindspring.com. We would love to spend an evening picking the brain of an experienced programmer like yourself.
Thanx again
Dr. G (Neil)
>Oh Neil,
>I will look into it later but as a quick reply I have :
>.Activate
>
>Just before "endwith". It makes the word window active one (not only visible but active too) so foregroundwindow handle belongs to word. Maybe just adding it would cure your problem.
>Cetin
>
>>Hi Cetin,
>>
>>You are always there when I need you. Thanx again. You are very close. I was able to place vfp code after your stuff which did not cause Word to minimize. That is a good thing. However, when I exited Word, vfp would not repsond to mouse clicks. In fact, the mouse pointer assumed the hourglass configuration and I had to ctrl-alt-del to ger out of vfp. Please review your code and advise me.
>>
>>P.S. Also try this. Populate the form's de with a table. Upon returning from Word please make certian you can still acess the table in vfp code ie: try to replace cname with "Neil".
>>
>>>>Hi Out there,
>>>>
>>>>I use Word97 as an automation server by coding the following in the click event of a command button.
>>>>
>>>>oWord = CreateObject("Word.Application")
>>>>with oWord
>>>> .Windowstate=0 &&
>>>> .visible = .t.
>>>> .document(add)
>>>>endwith
>>>>
>>>>
>>>>Word opens, a new dociment is dosplayed and Word remains open and in WINDOWSTATE=0 until I hit the close button. That is the functionality I want. However, if I place the simplest command after the endwith line, ie: messagebox('HI'), Word minimizes and that line of code executes. I don't want that line of code to execute until I close Word.
>>>>
>>>>How do you do it?
>>>>
>>>>Thanx Neil
>>>>dadigidoc@aol.com
>>>
>>>
Hi Neil,
>>>
If type("gHwndWord") = "U"
>>> Public gHwndWord
>>>Endif
>>>
>>>Declare integer GetForegroundWindow in WIN32API
>>>Declare short IsWindow in WIN32API integer
>>>
>>>********************
>>>* Create word object
>>>********************
>>>If type("oWordDocument") = "O" ;
>>> and type("gHwndWord") = "N" ;
>>> and IsWindow(gHwndWord) # 0
>>> oWordDocument=getobject(, "Word.application")
>>>Else
>>> oWordDocument=createobject("word.application")
>>>Endif
>>>********************
>>>* Create word object
>>>********************
>>>
>>>With oWordDocument
>>>*...
>>>Endwith
>>>
>>>gHwndWord = GetForegroundWindow()
>>>Do while IsWindow(gHwndWord) # 0
>>>Enddo
>>>Clear dlls
>>>oWordDocument=.Null.
Cetin