The Window object represents a specific InfoPath window. This object provides properties and methods that are used to interact with windows and access the underlying data associated with the window. Table A.3 shows the properties and methods of the Window object.
Name | Security Level | Description |
---|---|---|
Active Property | 1 | Is a Boolean that indicates whether the current window is active |
CommandBars Property | 3 | Returns an object reference to the Microsoft Office CommandBars object |
MailEnvelope Property | 2 | Returns a reference to the MailEnvelope property |
Type Property | 1 | Returns 0 to indicate an Editing Window and 1 to indicate a Designer Window |
TaskPanes Property | 1 | Returns an object reference to the TaskPanes collection |
XDocument Property | 2 | Returns an object reference to the associated XDocument object for the current window |
Activate Method | N/A | Designates the current window as active |
Close Method | N/A | Closes the currently active window |
The following example uses the Close method of the Window object to close the currently active window and force a save if any changes in the form have occurred:
Application.ActiveWindow.Close(false);
Note | It is important to review the security level of the properties used. For example, the CommandBars object can be used only in a fully trusted form. Otherwise, it will return permission denied . |