XmlFormCollection.NewFromFormTemplate Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
NewFromFormTemplate(String) |
Creates a new form that is based on the specified form template, with optional data. |
NewFromFormTemplate(String, String) |
Creates a new form that uses the specified form template and XML data file. |
NewFromFormTemplate(String, XPathNavigator) |
Creates a new form by using the specified form template with data specified by an XPathNavigator object. |
NewFromFormTemplate(String, String, XmlFormOpenMode) |
Creates a new form by using the specified form template with data specified by an XPathNavigator object and opened in the specified XmlFormOpenMode. |
NewFromFormTemplate(String)
Creates a new form that is based on the specified form template, with optional data.
public:
abstract Microsoft::Office::InfoPath::XmlForm ^ NewFromFormTemplate(System::String ^ formTemplateLocation);
public abstract Microsoft.Office.InfoPath.XmlForm NewFromFormTemplate (string formTemplateLocation);
abstract member NewFromFormTemplate : string -> Microsoft.Office.InfoPath.XmlForm
Public MustOverride Function NewFromFormTemplate (formTemplateLocation As String) As XmlForm
Parameters
- formTemplateLocation
- String
The Uniform Resource Identifier (URI) of the form template on which to base the new form.
Returns
An XmlForm object that represents the new form that was created.
Exceptions
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.
Examples
In the following code example, the NewFromFormTemplate(formTemplateLocation
) method of the XmlFormCollection class is passed the URI of an existing form template and the new form's associated XmlForm object is returned.
XmlForm newDocument =
this.Application.XmlForms.NewFromFormTemplate(
@"C:\MyForm.xsn");
Dim newDocument As XmlForm = _
Me.Application.XmlForms.NewFromFormTemplate(_
"C:\MyForm.xsn")
Remarks
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(String, XmlFormOpenMode) 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.
Applies to
NewFromFormTemplate(String, String)
Creates a new form that uses the specified form template and XML data file.
public:
abstract Microsoft::Office::InfoPath::XmlForm ^ NewFromFormTemplate(System::String ^ formTemplateLocation, System::String ^ xmlData);
public abstract Microsoft.Office.InfoPath.XmlForm NewFromFormTemplate (string formTemplateLocation, string xmlData);
abstract member NewFromFormTemplate : string * string -> Microsoft.Office.InfoPath.XmlForm
Public MustOverride Function NewFromFormTemplate (formTemplateLocation As String, xmlData As String) As XmlForm
Parameters
- formTemplateLocation
- String
The Uniform Resource Identifier (URI) of the form template on which to base the new form.
- xmlData
- String
The Uniform Resource Identifier (URI) of the XML document that provides the XML data to be used as a template for the form.
Returns
An XmlForm object that represents the new form that was created.
Exceptions
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.
Examples
In the following code example, the NewFromFormTemplate(formTemplateLocation
, xmlData
) method of the XmlFormCollection class is passed the URI of an existing form template, the URI of XML data, and the new form's associated XmlForm object is returned.
XmlForm newDocument =
this.Application.XmlForms.NewFromFormTemplate(
@"C:\MyForm.xsn", @"C:\MyForm.xml");
Dim newDocument As XmlForm = _
Me.Application.XmlForms.NewFromFormTemplate(_
"C:\MyForm.xsn", "C:\MyForm.xml")
Remarks
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(String, XmlFormOpenMode) 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.
Applies to
NewFromFormTemplate(String, XPathNavigator)
Creates a new form by using the specified form template with data specified by an XPathNavigator object.
public:
abstract Microsoft::Office::InfoPath::XmlForm ^ NewFromFormTemplate(System::String ^ formTemplateLocation, System::Xml::XPath::XPathNavigator ^ xmlData);
public abstract Microsoft.Office.InfoPath.XmlForm NewFromFormTemplate (string formTemplateLocation, System.Xml.XPath.XPathNavigator xmlData);
abstract member NewFromFormTemplate : string * System.Xml.XPath.XPathNavigator -> Microsoft.Office.InfoPath.XmlForm
Public MustOverride Function NewFromFormTemplate (formTemplateLocation As String, xmlData As XPathNavigator) As XmlForm
Parameters
- formTemplateLocation
- String
The Uniform Resource Identifier (URI) of the form template on which to base the new form.
- xmlData
- XPathNavigator
An XPathNavigator object that returns the XML data to be used as a template for the form.
Returns
An XmlForm object that represents the new form that was created.
Exceptions
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.
Examples
In the following code example, the NewFromFormTemplate(formTemplateLocation
, xmlData
) method of the XmlFormCollection class is passed the URI of an existing form template and an XPathNavigator object that returns XML data, and the new form's associated XmlForm object returned.
// Create an in-memory XML document.
XmlDocument newDoc = new XmlDocument();
// Load the document with some XML.
newDoc.LoadXml(
"<?xml version=\"1.0\" encoding=\"utf-8\" ?><person><firstName/><lastName/><address/><city/><country/></person>");
// Create an XPathNavigator for the XML file.
XPathNavigator newDocNav = newDoc.CreateNavigator();
// Call NewFromFormTemplate to open new form and load XML.
XmlForm newDocument =
this.Application.XmlForms.NewFromFormTemplate(
@"C:\MyForm.xsn", newDocNav);
' Create an in-memory XML document.
Dim newDoc As XmlDocument = new XmlDocument()
' Create XML to load.
Dim xmlToLoad As String = "<?xml version=" & Quote & "1.0" & Quote & _
" encoding=" & Quote & "utf-8" & Quote & _
" ?><person><firstName/><lastName/><address/>" & _
"<city/><country/></person>"
' Load the document with some XML.
newDoc.LoadXml(
)
' Create an XPathNavigator for the XML file.
Dim newDocNav As XPathNavigator = newDoc.CreateNavigator()
' Call NewFromFormTemplate to open new form and load XML.
Dim newDocument As XmlForm = _
Me.Application.XmlForms.NewFromFormTemplate(_
"C:\MyForm.xsn", newDocNav)
Remarks
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(String, XmlFormOpenMode) 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.
Applies to
NewFromFormTemplate(String, String, XmlFormOpenMode)
Creates a new form by using the specified form template with data specified by an XPathNavigator object and opened in the specified XmlFormOpenMode.
public:
abstract Microsoft::Office::InfoPath::XmlForm ^ NewFromFormTemplate(System::String ^ formTemplateLocation, System::String ^ xmlData, Microsoft::Office::InfoPath::XmlFormOpenMode behavior);
public abstract Microsoft.Office.InfoPath.XmlForm NewFromFormTemplate (string formTemplateLocation, string xmlData, Microsoft.Office.InfoPath.XmlFormOpenMode behavior);
abstract member NewFromFormTemplate : string * string * Microsoft.Office.InfoPath.XmlFormOpenMode -> Microsoft.Office.InfoPath.XmlForm
Public MustOverride Function NewFromFormTemplate (formTemplateLocation As String, xmlData As String, behavior As XmlFormOpenMode) As XmlForm
Parameters
- formTemplateLocation
- String
The Uniform Resource Identifier (URI) of the form template on which to base the new form.
- xmlData
- String
The Uniform Resource Identifier (URI) of the XML document that provides the XML data to be used as a template for the form.
- behavior
- XmlFormOpenMode
An XmlFormOpenMode enumeration that specifies how the form will be opened.
Returns
An XmlForm object that represents the new form that was created.
Exceptions
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.
Examples
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 =
this.Application.XmlForms.NewFromFormTemplate(
@"C:\MyForm.xsn", @"C:\MyForm.xml",
XmlFormOpenMode.FailOnVersionOlder);
Dim newDocument As XmlForm = _
Me.Application.XmlForms.NewFromFormTemplate(_
"C:\MyForm.xsn", XmlFormOpenMode.FailOnVersionOlder)
Remarks
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(String, XmlFormOpenMode) 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.