Automating InfoPath
Microsoft Office InfoPath 2003 Service Pack 1 offers expanded application automation in the form of methods of the Application object and the XDocuments collection.
Overview of the Application and XDocument objects
The Application object contains the following methods used for automation:
Method | Description |
---|---|
CacheSolution | Examines the form template in the cache and, if necessary, updates it from the published location of the form template. |
Quit | Quits the Microsoft Office InfoPath 2003 application. |
RegisterSolution | Installs the specified Microsoft Office InfoPath form template. |
UnregisterSolution | Uninstalls the specified Microsoft Office InfoPath 2003 form template. |
The XDocuments collection contains the following methods that can be used for external automation:
Method | Description |
---|---|
Close | Closes the specified Microsoft Office InfoPath 2003 form. |
New | Creates a new Microsoft Office InfoPath 2003 form based on the specified form. |
NewFromSolution | Creates a new Microsoft Office InfoPath 2003 form based on the specified form template. |
NewFromSolutionWithData | Creates a new Microsoft Office InfoPath 2003 form using the specified XML data and form template. |
Open | Opens the specified Microsoft Office InfoPath 2003 form. |
Note If the Disable Service Pack features option on the Advanced tab of the Options dialog box in InfoPath is selected, using the methods of the Application and XDocuments objects will result in an error when the Component Object Model (COM) server times out.
For backward compatibility, the automation of InfoPath is accomplished by using the ExternalApplication object from a programming language or environment that supports the Component Object Model (COM).
Overview of the ExternalApplication object
The ExternalApplication object provides the following methods that form developers can use to automate InfoPath.
Name | Description |
---|---|
CacheSolution method | Places the specified form template in a cache |
Close method | Closes the specified form |
New method | Creates a new form based on the specified form |
NewFromSolution method | Creates a new form based on the specified form template |
Open method | Opens the specified form |
Quit method | Quits the InfoPath application |
RegisterSolution method | Installs the specified form template |
UnregisterSolution method | Uninstalls the specified form template |
Using the ExternalApplication object
To use the ExternalApplication object, you must first create a reference to the ProgID of the InfoPath object model along with the name of the ExternalApplication object. The following example demonstrates the creation of a reference to the ExternalApplication object using the Microsoft Visual Basic for Applications (VBA) programming language:
Dim objIP As Object
Set objIP = CreateObject("InfoPath.ExternalApplication")
After you have created a reference to the ExternalApplication object, you can use the methods that it provides to interact with InfoPath. For more information about how the methods of the ExternalApplication object are used, click the methods in the preceding table.