Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to determine if MS Word is already running
Message
From
31/10/2003 07:12:47
 
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00844785
Message ID:
00844875
Views:
14
Hi Stephen.

I can't use FindWindow to reliably tell if Word is already open. If it is, I would prefer to open multiple documents within the same Word instance (some users are running Office2000 and some OfficeXP).

Is there a way to determine if the WINWORD process is running from within VFP?


As Andy says, you can use GETOBJECT() to open multiple documents in the same instance of Word. However, if Word is not running, this will cause an error. So you really need code like this:
*** Use GetObject to grab a reference to an existing
*** instance of the server or create one if there is none
TRY
   oWord = GETOBJECT( , 'Word.Application' )
CATCH TO oErr
   IF oErr.ErrorNo = 1426
      oWord = CREATEOBJECT('Word.Application')
   ELSE
      THROW oErr
   ENDIF
ENDTRY
Previous
Reply
Map
View

Click here to load this message in the networking platform