Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
QUITting Word
Message
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Title:
QUITting Word
Miscellaneous
Thread ID:
00536327
Message ID:
00536327
Views:
37
After calling Word as an automation server from VFP and using it to create reports, I want to QUIT Word. Of course, if the user hasn't run the report, there will be no Word object. Hence I want to check for the existence of the Word object ("oWord"). The problem is that I cannot seem to find a fail-proof way to test for oWord's existence. I have tried:

IF TYPE('oWord')='O'

as well as various variations on the code below, but I get an error (also below) which indicates that, while the "IF" statements evaluate to .t., the method oWord.Quit fails.

Can anyone tell me what I can do to test for the object's existence and run the Quit method (effectively) only if it is there and quitable?

Thanks. Here is the code:

First, the error:
Error #: 1426
Message: OLE error code 0x800706ba: The RPC server is unavailable.
Program: PROCEDURE PROAPP.LETWORDGO D:\PROJECTS\OSDCONTACTS\PROAPP.VCT
Code: oWord.QUIT
Line #: 8

Next, my code:
*!* Code before default call is to release the Word server and doc if they have been instantiated
IF VARTYPE(oWord) = 'O'
IF TYPE('oWordDoc.Name') = 'C'
* set step on
oWordDoc.SAVED = .T.
oWordDoc.CLOSE
ENDIF
oWord.QUIT
ENDIF
RELEASE oWord, oWordDoc

Jim Wheelock
Jim Wheelock
Next
Reply
Map
View

Click here to load this message in the networking platform