例: Style property (NotesRichTextTable - LotusScript®)

  1. 次のエージェントは、アイテム内で最初の (または唯一の) 表スタイルを取得します。

    Function GetStyleString(Byval styleCode As Long) As String
      Select Case styleCode
      Case TABLESTYLE_ALTERNATINGCOLS
        GetStyleString = "Alternating columns"
      Case TABLESTYLE_ALTERNATINGROWS
        GetStyleString = "Alternating rows"
      Case TABLESTYLE_LEFT
        GetStyleString = "Left"
      Case TABLESTYLE_LEFTTOP
        GetStyleString = "Left top"
      Case TABLESTYLE_NONE
        GetStyleString = "None"
      Case TABLESTYLE_RIGHT
        GetStyleString = "Right"
      Case TABLESTYLE_RIGHTTOP
        GetStyleString = "Right top"
      Case TABLESTYLE_SOLID
        GetStyleString = "Solid"
      Case TABLESTYLE_TOP
        GetStyleString = "Top"
      End Select
    End Function
    
    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_TABLE) Then
        Messagebox "Body item does not contain a table,",, _
        "Error"
        Exit Sub
      End If
      Dim rtt As NotesRichTextTable
      Set rtt = rtnav.GetElement
      colorStyle$ = GetStyleString(rtt.Style)
      Messagebox "Style = " & colorStyle$,, _
      "NotesRichTextTable"
    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_TABLE) Then
        Messagebox "Body item does not contain a table,",, _
        "Error"
        Exit Sub
      End If
      Dim rtt As NotesRichTextTable
      Set rtt = rtnav.GetElement
      rtt.Style = TABLESTYLE_ALTERNATINGROWS
      Dim colorObject As NotesColorObject
      Set colorObject = session.CreateColorObject
      colorObject.NotesColor = COLOR_BLUE
      Call rtt.SetColor(colorObject)
      colorObject.NotesColor = COLOR_YELLOW
      Call rtt.SetAlternateColor(colorObject)
      Call doc.Save(True, True)
    End Sub