Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Word Automation - avoiding 2 copies of Word
Message
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00748221
Message ID:
00748283
Views:
13
>This is because CREATEOBJECT() always creates a new instance of Word.
>What you need to do is use GETOBJECT() to grab a reference to an
>existing instance of Word. Unfortunately, the GETOBJECT() syntax can
>crash with error 1426 if there is no existing reference. This code should
>help get you started:

And, the VFP8 version:
LOCAL oerr as Exception
*** 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
P.S. -- Hey, Michel, you need some new syntax coloring code. :-)
My blog
My consulting page
My home page

Member of the Trim Your Auto-Quote Campaign!
What's another word for thesaurus?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform