New Method (ExternalApplication Object)

Microsoft Office InfoPath

Show All Show All

New Method (ExternalApplication Object)

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

expression.New(ByVal bstrDocumentURI As String, [ByVal dwBehavior As Long = 1])

expression    Required. An expression that returns a reference to the ExternalApplication object.

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

dwBehavior Optional Long. Default value is 1. A long value that specifies how the form should be opened. The values are based on the XdDocumentVersionMode enumeration.

Security Level

3: Can be accessed only by fully trusted forms.

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 method of the ExternalApplication object.

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

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

Example

In the following example, which is written in the Visual Basic for Applications (VBA) programming language, the New method of the ExternalApplication object is used to create a new form based on a specified form:

    Public Sub CreateFromForm()

   Dim objIP As Object

   'Create a reference to the ExternalApplication object.
   Set objIP = CreateObject("InfoPath.ExternalApplication")

   'Create an InfoPath form.
   objIP.New ("C:\My Forms\Form1.xml")
   MsgBox ("The InfoPath form has been created.")

   Set objIP = Nothing

End Sub