ExternalApplication.Open Method

InfoPath Developer Reference

Opens the specified Microsoft Office InfoPath 2007 form.

Version Information
 Version Added:  InfoPath 2003

Syntax

expression.Open(bstrDocumentURI, dwBehavior)

expression   An expression that returns a ExternalApplication object.

Parameters

Name Required/Optional Data Type Description
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.

Return Value
Nothing

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.

Security Level 3: Can be accessed only by fully trusted forms.

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:

Visual Basic for Applications
  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

See Also