例: IsExpanded property (NotesRichTextItem - LotusScript®)

  1. 次のエージェントは、リッチテキストアイテム内の各セクションの展開状態を表示します。

    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
      Do
        Set rts = rtnav.GetElement
        If rts.IsExpanded Then
          Messagebox "Section is expanded",, rts.Title
        Else
          Messagebox "Section is not expanded",, rts.Title
        End If
      Loop While rtnav.FindNextElement
    End Sub
  2. 次のエージェントは、リッチテキストアイテム内の各セクションの展開状態を切り替えます。

    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
      Do
        Set rts = rtnav.GetElement
        If rts.IsExpanded Then
          rts.IsExpanded = False
        Else
          rts.IsExpanded = True
        End If
      Loop While rtnav.FindNextElement(RTELEM_TYPE_SECTION, 1)
      Call doc.Save(True, True)
    End Sub