Show All

# Open Method (XDocuments Collection)

Opens the specified Microsoft Office InfoPath 2003 form.

expression.Open(ByVal varURI As Variant, [ByVal dwBehavior As Long = 1]) As XDocument

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

varURI Required Variant. Specifies the Uniform Resource Identifier (URI) of a form.

dwBehavior Optional Long. Default value is 1. A long value that specifies how the form should be opened. The values are based on the XdDocumentVersionMode enumeration.

returns 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 Open method can only be used to open a form; it cannot be used to open a form template. To create a form from a form template, use the NewFromSolution method of the XDocuments collection. To create a form based on an existing form, use the New method of the XDocuments collection.

When you use the Open method, the specified form opens in InfoPath and is ready to be filled out.

Note If you use the optional dwBehavior argument in the Open method, you can only pass the numerical value of the XdDocumentVersionMode enumeration. Because InfoPath uses scripting languages for working with the object model, named values cannot be used.

## Example

In the following example, the Open method of the XDocuments collection is passed the URI of an existing form, and the form is opened and its associated XDocument object returned:

    var objXDoc;

    objXDoc = Application.XDocuments.Open("C:\\MyForm.xml");

©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