Share via


ExternalApplication.Close Method

InfoPath Developer Reference

Closes the specified Microsoft Office InfoPath 2007 form.

Version Information
 Version Added:  InfoPath 2003

Syntax

expression.Close(bstrDocumentURI)

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.

Return Value
Nothing

Remarks

The Close method closes the currently open form without quitting the InfoPath application. When using the Close method, the form is closed unconditionally, meaning that any changes made to the data in the form are not saved.

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 Close method of the ExternalApplication object is used to close the currently open 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