例: FindNextElement method

次のエージェントは、現在 (または最初に) 選択されている文書の Body アイテム内の各段落を表示します。

Sub Initialize
  Dim session As New NotesSession
  Dim db As NotesDatabase
  Dim dc As NotesDocumentCollection
  Dim doc As NotesDocument
  Dim body As NotesRichTextItem
  Dim rtnav As NotesRichTextNavigator
  Dim rtrange As NotesRichTextRange
  Set db = session.CurrentDatabase
  Set dc = db.UnprocessedDocuments
  If dc.Count = 0 Then
    Messagebox "No document selected",, "No doc"
    Exit Sub
  End If
  Set doc = dc.GetFirstDocument
  Set body = doc.GetFirstItem("Body")
  Set rtnav = body.CreateNavigator
  If rtnav.FindFirstElement(RTELEM_TYPE_TEXTPARAGRAPH) Then
    Set rtrange = body.CreateRange
    count% = 0
    Do
      count% = count% + 1
      Call rtrange.SetBegin(rtnav)
      Messagebox rtrange.TextParagraph,, "Paragraph " & count%
    Loop While rtnav.FindNextElement(RTELEM_TYPE_TEXTPARAGRAPH)
 Else
    Messagebox "No text in Body",, "No text"
  End If
End Sub