Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
QUITting Word
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Titre:
Divers
Thread ID:
00536327
Message ID:
00536330
Vues:
8
Hi!
*!* 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
        lcOldError = ON("ERROR")
        ON ERROR llError=.T.
        oWord.QUIT
        ON ERROR &lcOldError
ENDIF
RELEASE oWord, oWordDoc
If you have the Error method code defined, disable errors there just by returning from it when certain condition (for example, flag property is set to .T.). Than set flag before quitting from Word.

HTH.

>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
Vlad Grynchyshyn, Project Manager, MCP
vgryn@yahoo.com
ICQ #10709245
The professional level of programmer could be determined by level of stupidity of his/her bugs

It is not appropriate to say that question is "foolish". There could be only foolish answers. Everybody passed period of time when knows nothing about something.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform