Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Prohibit MS Word from being closed from VFP
Message
 
 
À
02/03/2005 13:54:08
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 7 SP1
OS:
Windows '98
Network:
Novell 5.x
Database:
Visual FoxPro
Divers
Thread ID:
00992096
Message ID:
00992114
Vues:
18
Larry,

Instead of trying to prevent the user from closing Word, you can write code to use an open instance if there is one or create a new instance if there isn't one. Before structured error handling it could look like this
LOCAL lcOldError, llFail
lcOldError = ON("error")
ON ERROR llFail = .T.
loWord = GetObject(, "Word.Application")
IF llFail
   loWord = CREATEOBJECT( "Word.Application")
ENDIF
ON ERROR &lcOldError
With the benefit of structured error handling in VFP 8.0 and later, you can simply do this
TRY
   loWord = GetObject(, "Word.Application")
CATCH
   loWord = CREATEOBJECT( "Word.Application")
ENDTRY
HTH,

-Rick


>I have an app in VFP7.0 that creates MS Word documents using the database. I usually keep Word in the background using oWord.visible = FALSE. Some of these documents need to be displayed however. I am having a problem if the user clicks the "X" to close Word instead of just the document. I wrote some code to check if Word is open and if not reopen it, but very often this results in a Microsoft Windows error. It would be easier if I could disable the "X" (quit) from the upper right of the MS Word window. Is there a way to do that when I'm opening MS Word from VFP.
>
>Larry Morelli
Rick Borup, MCSD

recursion (rE-kur'-shun) n.
  see recursion.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform