次のエージェントは、選択した文書の Body アイテム内にある各タイプの要素の数を表示します。
Dim session As NotesSession
Dim db As NotesDatabase
Dim dc As NotesDocumentCollection
Dim doc As NotesDocument
Dim rti As NotesRichTextItem
Dim rtnav As NotesRichTextNavigator
Sub Initialize
Set session = New NotesSession
Set db = session.CurrentDatabase
Set dc = db.UnprocessedDocuments
Set doc = dc.GetFirstDocument
If dc.Count = 0 Then
Messagebox "Nothing selected",, "No documents"
Exit Sub
End If
Set rti = doc.GetFirstItem("Body")
Set rtnav = rti.CreateNavigator
Messagebox _
"Number of doc links = " & _
GetCount(RTELEM_TYPE_DOCLINK) & Chr(13) & _
"Number of file attachments = " & _
GetCount(RTELEM_TYPE_FILEATTACHMENT) & Chr(13) & _
"Number of OLE objects = " & _
GetCount(RTELEM_TYPE_OLE) & Chr(13) & _
"Number of sections = " & _
GetCount(RTELEM_TYPE_SECTION) & Chr(13) & _
"Number of tables = " & _
GetCount(RTELEM_TYPE_TABLE) & Chr(13) & _
"Number of table cells = " & _
GetCount(RTELEM_TYPE_TABLECELL) & Chr(13) & _
"Number of text paragraphs = " & _
GetCount(RTELEM_TYPE_TEXTPARAGRAPH) & Chr(13) & _
"Number of text runs = " & _
GetCount(RTELEM_TYPE_TEXTRUN),, _
"Elements in Body item"
End Sub
Function GetCount(elementType As Integer) As Integer
GetCount = 0
If rtnav.FindFirstElement(elementType) Then
Do
GetCount = GetCount + 1
Loop While rtnav.FindNextElement(elementType)
End If
End Function