Examples: Style property

This agent toggles between blue and red the color of the text content of the first table in the current document.

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 rtrangeTable As NotesRichTextRange
  Dim style As NotesRichTextStyle
  Set db = session.CurrentDatabase
  Set dc = db.UnprocessedDocuments
  Set doc = dc.GetFirstDocument
  Set body = doc.GetFirstItem("Body")
  REM Get first table in Body item
  REM Set range for it
  Set rtnavBody = body.CreateNavigator
  If Not rtnavBody.FindFirstElement(RTELEM_TYPE_TABLE) Then
    Messagebox "Body item does not contain a table,",, _
    "Error"
    Exit Sub
  End If
  Set rtrangeTable = body.CreateRange
  Call rtrangeTable.SetBegin(rtnavBody)
  Call rtrangeTable.SetEnd(rtnavBody)
  REM Get style of first text run in table
  Set style = rtrangeTable.Style
  REM Toggle color between blue and red
  If style.NotesColor = COLOR_BLUE Then
    style.NotesColor = COLOR_RED
  Else
    style.NotesColor = COLOR_BLUE
  End If
  REM Set table to new color
  Call rtrangeTable.SetStyle(style)
  Call doc.Save(True, True, True)
End Sub