Close Method (ExternalApplication Object)

Microsoft Office InfoPath

Show All Show All

Close Method (ExternalApplication Object)

Closes the specified Microsoft Office InfoPath 2003 form.

expression.Close(ByVal bstrDocumentURI As String)

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.

Security Level

3: Can be accessed only by fully trusted forms.

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.

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:

    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