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.