Open Method (ExternalApplication Object)

Microsoft Office InfoPath

Show All Show All

Open Method (ExternalApplication Object)

Opens the specified Microsoft Office InfoPath 2003 form.

expression.Open(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 Open method can be used only to open a form; it cannot be used to open a form template. To create a form from a form template, use the NewFromSolution method of the ExternalApplication object. To create a form based on an existing form, use the New method of the ExternalApplication object.

Example

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

    Public Sub AutomateInfoPathForm()

   Dim objIP As Object

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

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

   'Close the InfoPath form.
   objIP.Close ("C:\My Forms\Form1.xml")
   MsgBox ("The InfoPath form has been closed.")

   'Quit the InfoPath application.
   objIP.Quit
   MsgBox ("The InfoPath application has been closed.")

   Set objIP = Nothing

End Sub