Programming the XDocuments Collection

Testing the Count property of the XDocuments collection lets you determine how many instances of a template’s form are open, as described in Table 16-2. The following code in XDocumentsAlert.txt adds an alert, which displays information about all forms and the active form, to the btnViewItems_OnClick event handler:

 With thisApplication.ActiveWindow 'Display an informative alert if more than one form is open Dim intNumXDocs As Integer = thisApplication.XDocuments.Count Dim strXDocNames As String Dim strName As String = .Caption Dim strType As String = .WindowType.ToString Dim strState As String = .WindowState.ToString Dim intCtr As Integer For intCtr = 0 To intNumXDocs - 1 'Get the open form's caption in ...

Get Introducing Microsoft® Office InfoPath™ 2003 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.