Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Killing Word processes
Message
 
 
À
07/07/2000 05:25:00
Paul Robinshaw
Silkworm Technologies Limited
Macclesfield, Royaume Uni
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Divers
Thread ID:
00389350
Message ID:
00390155
Vues:
10
>Hi All,
>
>I have an app that automates Word. From time to time my users exit prematurely and the leaves an instance of Word running on the PC. On the next start up of the application they get two instances of Word running. Any ideas on how I can check for multiple instances of Word and possible kill one of them off?
>
>Regards
>
>Paul Robinshaw

Paul,
You could use the GetObject function instead of CreateObject. CreateObject creats a new sinatnce everytime where GetObject grabs an already existing instance (if one exists).

Try the following:
local llerror
llerror = .F.
lcerror = on('error')
on error *
oWord = GetObject(,"word.application")
if vartype(oWord) = "O" then
   * you got an already existing Word reference
else
   * if no Word instance exists, VFP throws an OLE error (that is the reason for the on error)
   * create new instance now
   oWord = createobject("word.application")
endif
if !empty(lcerror) then
   on error &lcerror
endif
Larry Miller
MCSD
LWMiller3@verizon.net

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

Click here to load this message in the networking platform