NewFromFormTemplate method (String, String, XmlFormOpenMode)

XmlFormCollection.NewFromFormTemplate method (String, String, XmlFormOpenMode)

Office 2013 and later

Creates a new form by using the specified form template with data specified by an XPathNavigator object and opened in the specified XmlFormOpenMode.

Namespace:  Microsoft.Office.InfoPath
Assembly:  Microsoft.Office.InfoPath (in Microsoft.Office.InfoPath.dll)

public abstract XmlForm NewFromFormTemplate(
	string formTemplateLocation,
	string xmlData,
	XmlFormOpenMode behavior


Type: System.String

The Uniform Resource Identifier (URI) of the form template on which to base the new form.

Type: System.String

The Uniform Resource Identifier (URI) of the XML document that provides the XML data to be used as a template for the form.

Type: Microsoft.Office.InfoPath.XmlFormOpenMode

An XmlFormOpenMode enumeration that specifies how the form will be opened.

Return value

Type: Microsoft.Office.InfoPath.XmlForm
An XmlForm object that represents the new form that was created.


The parameter that was passed to this method is not valid. For example, it is of the wrong type or format.


The parameter that was passed to this method is a null reference (Nothing in Visual Basic).


The file specified for formTemplateLocation does not exist.


This method was called from an event handler for the Loading event.

The NewFromFormTemplate method can only be used to create a new form that is based on an existing form template; it cannot be used to create a new form that is based on a form. To create a form from an existing form, use the New method.

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

This member 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.

This type or member can be accessed only from code running in forms opened in Microsoft InfoPath Filler.

In the following code example, the NewFromFormTemplate(formTemplateLocation, xmlData,behavior) method of the XmlFormCollection class is passed the URI of an existing form template, the URI of XML data, an XmlFormOpenMode enumeration, and the new form's associated XmlForm object is returned.

XmlForm newDocument = 
   @"C:\MyForm.xsn", @"C:\MyForm.xml", 
© 2016 Microsoft