Help and Support
 

powered byLive Search

The XDocumentBeforeClose event does not occur when you exit InfoPath 2007 without first closing a form

Article ID:922210
Last Review:February 7, 2007
Revision:1.3

SYMPTOMS

Consider the following scenario:
You design a new Microsoft Visual C# Add-in project for Microsoft Office InfoPath 2007.
You use the following code example to change the OnConnection event method. This code example also changes the applicationObject definition to Private ApplicationClass applicationObject;.
applicationObject = (ApplicationClass)application;
	addInInstance = addInInst;

            ((ApplicationEventsClass)applicationObject.Events).XDocumentBeforeClose += new 			_ApplicationEvents_XDocumentBeforeCloseEventHandler(Connect_XDocumentBeforeClose);

You add a method definition that resembles the following code example.
void Connect_XDocumentBeforeClose(_XDocument pDocument, ref bool pfCancel)
        	{
	            System.Windows.Forms.MessageBox.Show("Connect_XDocumentBeforeClose");
        	}
You build and install the new add-in.
You open the form in InfoPath 2007.
You exit InfoPath 2007 without first closing the form.
In this scenario, the XDocumentBeforeClose event does not occur.

Back to the top

CAUSE

This behavior occurs because the XDocumentBeforeClose event may prevent InfoPath 2007 to shut down by returning "fCancel=true". However, if the XDocumentBeforeClose event is called, the event is ignored, and the returned value may confuse some third-party developers. Therefore, use the Application::Quit command if you must perform cleanup tasks related to opened documents.

Back to the top

STATUS

This behavior is by design.

Back to the top


APPLIES TO
Microsoft Office InfoPath 2007

Back to the top

Keywords: 
kbtshoot kbprb KB922210

Back to the top

Article Translations

 

Related Support Centers

Other Support Options

  • Need More Help?
    Contact a Support professional by E-mail, Online or Phone.
  • Customer Service
    For non-technical assistance with product purchases, subscriptions, online services, events, training courses, corporate sales, piracy issues, and more.
  • Newsgroups
    Pose a question to other users. Discussion groups and Forums about specific Microsoft products, technologies, and services.