Share via


Window.Close Method

InfoPath Developer Reference

Closes the window that is represented by the Window object.

Version Information
 Version Added:  InfoPath 2003

Syntax

expression.Close(fForce)

expression   An expression that returns a Window object.

Parameters

Name Required/Optional Data Type Description
fForce Optional Boolean Default value is False. Determines whether open documents will be saved.

Return Value
Nothing

Remarks

The Close method will close the associated window and the forms that it contains. If the bForce parameter is set to True, all forms will be closed without saving, even if they contain changes since they were last saved. If set to False, users will be prompted to save their changes.

The Close method can be used only with the editing window types; if used with a designing window type, it will return an error. In addition, the Close method can only be used with the OnSubmitRequest and OnClick event handlers. If used with any other type of event handler, it will return an error.

Bb229754.vs_note(en-us,office.12).gif  Note
If the window being closed is the only window open in Microsoft Office InfoPath 2007, the InfoPath application will also be closed.

Security Level 2: Can be accessed only by forms running in the same domain as the currently open form, or by forms that have been granted cross-domain permissions.

Example

In the following example, the Close method of the Window object is used to close the currently active window, forcing a save if changes in the form have occurred:

JScript
  Application.ActiveWindow.Close(false);

See Also