Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Killing Word processes
Message
 
 
To
07/07/2000 05:25:00
Paul Robinshaw
Silkworm Technologies Limited
Macclesfield, United Kingdom
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00389350
Message ID:
00390155
Views:
11
>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
Previous
Reply
Map
View

Click here to load this message in the networking platform