Accessing application data

Microsoft Office InfoPath

Show All Show All

Accessing application data

The Microsoft Office InfoPath 2003 object model provides objects and collections that can be used to gain access to information about the InfoPath application, including information related to a form's underlying XML document and the form definition (.xsf) file. This data is accessed through the top-level object in the InfoPath object model hierarchy— the Application object.

Using the Application object, InfoPath form developers can access information about the currently installed instance of InfoPath, including its name and version number. In the following example, the Name and Version properties of the Application object return data in a message box to the user:

    Application.XDocuments(0).UI.Alert("Application name: " + Application.Name +
   "\nApplication version: " + Application.Version);

  

Note that the Alert method of the UI object, which is accessed through the XDocument object, is used to display a message box to the user. Because the XDocument object that represents the currently open form's underlying XML document is embedded in the InfoPath script engine, the previous example can also be written as follows:

    XDocument.UI.Alert("Application name: " + Application.Name +
   "\nApplication version: " + Application.Version);

  

Note  The \n character references in the text for the alert message is a standard new line feed that causes the text to break and be placed on a new line in the message box.

ShowAccessing data about a form's XML document

ShowAccessing data about a form's .xsf file