>>>>>>>>BTW, the slow closing happens only on some machines, and only if there is no internet connect. I could not find any specific reason for that. The only cure might be re-installing Office and/or Windows, but that same problem could of course occur at a client, so that would not really be a solution we could offer.
>>>>>>>
>>>>>>>You shouldn't need to task kill Word, it will "kill itself" when there's no more reference to it, IOW when your application exits.
>>>>>>
>>>>>>that I cannot reproduce. If I instantiate the object, and close VFP, the Winword process stays there until I kill the task in the task manager.
>>>>>
>>>>>It turns out that you are right, much to my surprise. I am not sure, but I don't think that was the case with older Word versions. I checked Excel, and is released automatically.
>>>>
>>>>Now I am surprised as well, because I thought Excel behaves the same as Word, but you are right, it releases the process when the reference is cleared. Good to know, at least I don't need to worry for closing Excel.
>>>
>>>Ah, things from my memory bubbles up! I remember using this construct many years ago, when I did a lot of automation. This solution will make sure that the number of Word tasks won't increase unnecessary:
>>>
>>>Try
>>> loWord = GetObject(,'word.application')
>>>Catch
>>> loWord = CreateObject('word.application')
>>>Endtry
>>
>>That must have changed as well, because when I try GetObject it always returns an error Monikor cannot open file.
>>
>>What I now try is to create a singleton object with lazy instantiation of a word application object. At instantiation I get the process ID of the word process and when doing automation work it checks if the object is still alive, and when releasing the object it kills the process.
>
>Note the comma before 'word.application'!!
That does the trick. However I still don't understand the meaning of GetObject, because when you run getobject after you have done a successful createobject, it still would create a new process each time, and the process stays alive unless you issue the quit method. I believe this was differently previous to Word 2003 or Word 2000, somewhere in those versions the way how word handled the different windows was entirely different.
Christian Isberner
Software Consultant