PDA

View Full Version : Prevent Quit in Word?



let98007
06-29-2009, 03:40 PM
I have a Visual FoxPro application that creates and prints multiple documents using Word automation. Normally the entire process is invisible, but one document requires that the user be able to edit the contents. What I would like to do is bind an Eventhandler in VFP that implements word's ApplicationEvents2 interface. This would allow the user to edit without being able to open documents, create new ones, save or print. Once the user indicates they are through editing (currently that is done by clicking the Closebox but I am open to other suggestions!) I want to prevent the default Quit behavior in Word, unbind the eventhandler, and allow the automation code to continue to process the document in the usual manner.

The Print and Save procedures are no problem; they have a Cancel property to prevent default behavior. So far, I've been unable to control the Quit process.

Another problem I'm sure to face is how to force the VFP app to wait for the editing process to finish. Has anyone implemented something like this before?

geek2be
07-02-2009, 01:22 PM
I do not know much about visual foxpro but controlling the quit process should not be a hassle. when you say quit you mean closing word right or just the application or both?

let98007
07-02-2009, 09:29 PM
The object was to intercept the process and not allow the default behavior. Instead I wanted to return control to the automation process.

I have actually succeeded in doing this with the ApplicationEvents2 interface through the BeforeClose method. After 2 years of trying to make this work, it is finally functional!

Thanks for your response.