_ExternalApplication.Open(String, Int32) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Opens the specified Microsoft InfoPath form.
public void Open (string bstrDocumentURI, int dwBehavior = 1);
abstract member Open : string * int -> unit
Public Sub Open (bstrDocumentURI As String, Optional dwBehavior As Integer = 1)
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 Open method of the ExternalApplication object is used to open a form from the file system:
private void AutomateInfoPathForm()
{
ExternalApplication infoPath = new ExternalApplicationClass();
// Open an InfoPath form.
infoPath.<span class="label">Open</span>(@"C:\My Forms\Form1.xml", 1);
// Close the InfoPath form.
infoPath.Close(@"C:\My Forms\Form1.xml");
// Quit the InfoPath application.
infoPath.Quit();
}
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 Open method of the ExternalApplication object is used to open a form from the file system:
private void AutomateInfoPathForm()
{
ExternalApplication infoPath = new ExternalApplicationClass();
// Open an InfoPath form.
infoPath.<span class="label">Open</span>(@"C:\My Forms\Form1.xml", 1);
// Close the InfoPath form.
infoPath.Close(@"C:\My Forms\Form1.xml");
// Quit the InfoPath application.
infoPath.Quit();
}
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 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(String) method. To create a form based on an existing form, use the New(String, Int32) method.