Show All

# Close Method (XDocuments Collection)

Closes the specified Microsoft Office InfoPath 2003 form.

expression.Close(ByVal varIndex As Variant)

expression Required. An expression that returns a reference to the XDocuments collection.

varIndex Required Variant. The string value that specifies the Uniform Resource Identifier (URI) of a form, a long integer value that specifies the positional index of an XDocument object within the XDocuments collection, or a reference to an XDocument object.

## 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 closes the currently open form without quitting the InfoPath application. The form is closed unconditionally, meaning that any changes made to the data in the form are not saved.

## Example

In the following example, the Close method of the XDocuments collection is used to close the currently open form using the positional index of an XDocument object contained in the collection:

    Application.XDocuments.Close(0);

Alternatively, you can pass a reference to an XDocument object:

    var objXDoc;

    objXDoc = Application.XDocuments(0);
    Application.XDocuments.Close(objXDoc);

©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