例: TextRun property

次のエージェントは、すべてのテキスト段落内のすべてのテキストランを取得します。

Sub Initialize
  Dim session As New NotesSession
  Dim db As NotesDatabase
  Dim dc As NotesDocumentCollection
  Dim doc As NotesDocument
  Dim body As NotesRichTextItem
  Dim rtnavBody As NotesRichTextNavigator
  Dim rtnavPara As NotesRichTextNavigator
  Dim rtrangePara As NotesRichTextRange
  Dim rtrangeRun As NotesRichTextRange
  Dim paraCount As Integer
  Dim runCount As Integer
  Set db = session.CurrentDatabase
  Set dc = db.UnprocessedDocuments
  Set doc = dc.GetFirstDocument
  Set body = doc.GetFirstItem("Body")
  REM Get first paragraph in Body item
  REM Set range and navigator for it
  Set rtnavBody = body.CreateNavigator
  If Not rtnavBody.FindFirstElement(RTELEM_TYPE_TEXTPARAGRAPH) Then
    Messagebox "Body item does not contain text,",, _
    "Error"
    Exit Sub
  End If
  Set rtrangePara = body.CreateRange
  Set rtrangeRun = body.CreateRange
  Do
    paraCount = paraCount + 1
    runCount = 0
    Call rtrangePara.SetBegin(rtnavBody)
    Call rtrangePara.SetEnd(rtnavBody)
    Set rtnavPara = rtrangePara.Navigator
  REM Get each run in paragraph
  REM Display it
    Call rtnavPara.FindFirstElement(RTELEM_TYPE_TEXTRUN)
    Do
      runCount = runCount + 1
      Call rtrangeRun.SetBegin(rtnavPara)
      Messagebox rtrangeRun.TextRun,, _
      "Paragraph " & paraCount & ", Run " & runCount
    Loop While rtnavPara.FindNextElement(RTELEM_TYPE_TEXTRUN)
  Loop While rtnavBody.FindNextElement(RTELEM_TYPE_TEXTPARAGRAPH) 
End Sub