例: NotesRichTextNavigator class

次のエージェントは、現在 (または最初に) 選択されている文書の 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