Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Excel automation and procedures
Message
De
20/03/2018 18:02:40
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01658838
Message ID:
01658884
Vues:
47
>>>>>>>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'!!
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform