Examples: CreateRange method

This agent creates a range to access the text paragraphs in an item.

Dim session As 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

Sub Initialize
  Set session = New NotesSession
  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
    msg$ = ""
    Set rtrange = body.CreateRange
    Do
      Call rtrange.SetBegin(rtnav)
      msg$ = msg$ & rtrange.TextParagraph & Chr(10)
    Loop While rtnav.FindNextElement
    Messagebox msg$,, "Text of body"
  Else
    Messagebox "No text in Body",, "No text"
  End If
End Sub