Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to get my own copy of Word?
Message
 
 
À
21/11/2000 22:49:18
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Divers
Thread ID:
00444424
Message ID:
00444573
Vues:
7
>>I don't think it will work the way you want it to but there is a solution. Before you start word look to see if its already running by using getobject(,'Word.Application') instead of createobject. If word is already running then instead of closing word when you need to just close the document you are working on.
>
>That's a good idea. I'd rather have a solution that leaves word running (and I suspect there's an API'ish way to do it), but if I cannot find it, this is a good work around. Thanks.

This still doesn't address the problem of someone coming in during your processing after you have obtained a reference to Word using Createobject. You created an instance of Word. When a user launches Word while you have it open, they get your instance. Because you opened it with Createobject(), you think you can close it, but that will interfere with other things.

Always use createobject to initially get your instance. Even if Word is open, a new instance will be created. However, instead of just exiting out of Word, check the Documents.Count property first. If it is greater than 1 (the document you are working on) then you know to only set your variable to .NULL. and not call Quit first because someone else is using Word to do something.

The only (as I see it) issue that this doesn't correct is the problem of someone going into Word while you have it open and then they close it before you are done your processing. If they do that, then Word is closed and you lose your object reference. I don't know if there is a chance of this happening during the process you described.
Larry Miller
MCSD
LWMiller3@verizon.net

Accumulate learning by study, understand what you learn by questioning. -- Mingjiao
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform