Show All

# Close Method (Window Object)

Closes the window that is represented by the Window object.

expression.Close([ByVal bForce As Boolean])

expression Required. An expression that returns a reference to the Window object.

bForce Optional Boolean. Default value is False. Determines whether open documents will be saved.

## 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.

## 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.

Note If the window being closed is the only window open in Microsoft Office InfoPath 2003, the InfoPath application will also be closed.

## 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:

    Application.ActiveWindow.Close(false);

©2003-2004 Microsoft Corporation. All rights reserved. Permission to copy, display and distribute this document is available at: http://msdn.microsoft.com/library/en-us/odcXMLRef/html/odcXMLRefLegalNotice.asp