This documentation is archived and is not being maintained.

XDocuments.New Method

Office 2007
Creates a new Microsoft Office InfoPath 2007 form based on the specified form.

Version Information
 Version Added:  InfoPath 2003


expression.New(varURI, dwBehavior)

expression   An expression that returns a XDocuments object.


NameRequired/OptionalData TypeDescription
varURIRequiredVariantSpecifies the Uniform Resource Identifier (URI) of a form.
dwBehaviorOptionalLongOptional Long. Default value is 1. A long value that specifies how the form should be opened. The values are based on the XdDocumentVersionMode enumeration.

Return Value


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

The New method can only be used to create a new form based on an existing form; it cannot be used to create a new form based on a form template. To create a form from a form template, use the NewFromSolution method of the XDocuments collection.

Bb229786.vs_note(en-us,office.12).gif  Note
If you use the optional dwBehavior argument in the New 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.

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.


In the following example, the New method of the XDocuments collection is passed the URI of an existing form, and a new form is created and its associated XDocument object returned:

var objXDoc;

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