Edit

Share via


_ExternalApplication.New(String, Int32) Method

Definition

Creates a new Microsoft InfoPath form based on a specified form.

public:
 void New(System::String ^ bstrDocumentURI, int dwBehavior);
public void New (string bstrDocumentURI, int dwBehavior);
abstract member New : string * int -> unit
Public Sub New (bstrDocumentURI As String, dwBehavior As Integer)

Parameters

bstrDocumentURI
String

The string value that specifies the Uniform Resource Identifier (URI) of a form.

dwBehavior
Int32

Default value is 1. Specifies how the form should be opened. The values are based on the XdDocumentVersionMode enumeration.

Examples

In the following example, which is written in the C# programming language, the New method of the ExternalApplication object is used to create a new form based on a specified form:

private void CreateFromForm()
{
 ExternalApplication infoPath = new ExternalApplicationClass();

 // Create an InfoPath form.
 infoPath.<span class="label">New</span>(@"C:\My Forms\Form1.xml", 1);
}

Note: The above example assumes that the Microsoft.Office.Interop.InfoPath namespace is being used and that the Microsoft InfoPath 3.0 Type Library is referenced.

In the following example, which is written in the C# programming language, the New method of the ExternalApplication object is used to create a new form based on a specified form:

private void CreateFromForm()
{
 ExternalApplication infoPath = new ExternalApplicationClass();

 // Create an InfoPath form.
 infoPath.<span class="label">New</span>(@"C:\My Forms\Form1.xml", 1);
}

Note: The above example assumes that the Microsoft.Office.Interop.InfoPath namespace is being used and that the Microsoft InfoPath 3.0 Type Library is referenced.

Remarks

The New method can be used to only 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(String) method.

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

Note   You cannot use Close(String) to close a form that has been opened with the New method. When the New method creates a form, the name of that form is not yet known.

Important: 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.

Applies to