Examples: Title property (NotesRichTextSection - LotusScript®)

  1. This agent displays the title of each section in a rich text item.

    Sub Initialize
      Dim session As New NotesSession
      Dim db As NotesDatabase
      Set db = session.CurrentDatabase
      Dim dc As NotesDocumentCollection
      Set dc = db.UnprocessedDocuments
      Dim doc As NotesDocument
      Set doc = dc.GetFirstDocument
      Dim rti As NotesRichTextItem
      Set rti = doc.GetFirstItem("Body")
      Dim rtnav As NotesRichTextNavigator
      Set rtnav = rti.CreateNavigator
      If Not rtnav.FindFirstElement(RTELEM_TYPE_SECTION) Then
        Messagebox "Body item does not contain a section,",, _
        "Error"
        Exit Sub
      End If
      Dim rts As NotesRichTextSection
      count% = 0
      Do
        count% = count% + 1
        Set rts = rtnav.GetElement
        Messagebox "Section " & count%  _
        ,, rts.Title
      Loop While rtnav.FindNextElement
    End Sub
  2. This agent sets the title of each section in a rich text item.

    Sub Initialize
      Dim session As New NotesSession
      Dim db As NotesDatabase
      Set db = session.CurrentDatabase
      Dim dc As NotesDocumentCollection
      Set dc = db.UnprocessedDocuments
      Dim doc As NotesDocument
      Set doc = dc.GetFirstDocument
      Dim rti As NotesRichTextItem
      Set rti = doc.GetFirstItem("Body")
      Dim rtnav As NotesRichTextNavigator
      Set rtnav = rti.CreateNavigator
      If Not rtnav.FindFirstElement(RTELEM_TYPE_SECTION) Then
        Messagebox "Body item does not contain a section,",, _
        "Error"
        Exit Sub
      End If
      Dim rts As NotesRichTextSection
      count% = 0
      Do
        count% = count% + 1
        Set rts = rtnav.GetElement
        rts.Title = "Section " & count%
      Loop While rtnav.FindNextElement
      Call doc.Save(True, True)
    End Sub