次のエージェントは、現在の文書の Body アイテムにある最初の 2 つの段落を取得します。エージェントはあるナビゲータを使用して最初の段落を検索し、これを複製して、次に複製されたナビゲータを使用して 2 番目の段落を検索します。
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim dc As NotesDocumentCollection
Dim doc As NotesDocument
Dim body As NotesRichTextItem
Dim rtnavBody1 As NotesRichTextNavigator
Dim rtnavBody2 As NotesRichTextNavigator
Dim rtrangePara As NotesRichTextRange
Set db = session.CurrentDatabase
Set dc = db.UnprocessedDocuments
Set doc = dc.GetFirstDocument
Set body = doc.GetFirstItem("Body")
REM Set navigator to first paragraph in Body item
Set rtnavBody1 = body.CreateNavigator
If Not rtnavBody1.FindFirstElement(RTELEM_TYPE_TEXTPARAGRAPH) Then
Messagebox "Body item does not contain text,",, "Error"
Exit Sub
End If
REM Set cloned navigator to second paragraph in Body item
Set rtnavBody2 = rtnavBody1.Clone
If Not rtnavBody2.FindNextElement(RTELEM_TYPE_TEXTPARAGRAPH) Then
Messagebox "Body item does not contain two paragraphs,",, "Error"
Exit Sub
End If
REM Get first and second paragraphs
Set rtrangePara = body.CreateRange
Call rtrangePara.SetBegin(rtnavBody1)
Messagebox rtrangePara.TextParagraph,, "First paragraph"
Call rtrangePara.SetBegin(rtnavBody2)
Messagebox rtrangePara.TextParagraph,, "Second paragraph"
End Sub