XmlFormCollection.NewFromFormTemplateWithInputParameters method

Creates a new form with the specified form template and input parameters.

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

Syntax

'Declaration
Public MustOverride Function NewFromFormTemplateWithInputParameters ( _
    formTemplateLocation As String, _
    inputParameters As String _
) As XmlForm
'Usage
Dim instance As XmlFormCollection
Dim formTemplateLocation As String
Dim inputParameters As String
Dim returnValue As XmlForm

returnValue = instance.NewFromFormTemplateWithInputParameters(formTemplateLocation, _
    inputParameters)
public abstract XmlForm NewFromFormTemplateWithInputParameters(
    string formTemplateLocation,
    string inputParameters
)

Parameters

  • formTemplateLocation
    Type: System.String

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

  • inputParameters
    Type: System.String

    One or more name/value pairs separated by the ampersand (&) character.

Return value

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

Exceptions

Exception Condition
ArgumentException

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

ArgumentNullException

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

FileNotFoundException

The file specified for formTemplateLocation does not exist.

InvalidOperationException

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

Remarks

To use the input parameters that were passed to the inputParameters parameter, the form specified in the formTemplateLocation parameter must contain a Loading event handler that uses the InputParameters property of the LoadingEventArgs class to retrieve the input parameter values, and then do something with those values. For an example of how to do this, see the InputParameters property topic.

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

This member can be accessed only by forms opened from a form template that has been configured to run with full trust using the Security and Trust category of the Form Options dialog box. This member requires full trust for the immediate caller and cannot be used by partially trusted code. For more information, see "Using Libraries from Partially Trusted Code" on MSDN.

Examples

The following code example shows how to create a new form by passing in the URI of a form template that contains an appropriate Loading event handler and two input parameters.

XmlForm newDocument = 
   this.Application.XmlForms.NewFromFormTemplateWithParameters(
   @"C:\User Forms\DeptReport.xsn","Dept=Accounting&Acct=Contoso");
Dim newDocument As XmlForm = _
   Me.Application.XmlForms.NewFromFormTemplateWithParameters( _
   "C:\User Forms\DeptReport.xsn","Dept=Accounting&Acct=Contoso")

See also

Reference

XmlFormCollection class

XmlFormCollection members

Microsoft.Office.InfoPath namespace