- This agent creates a document, creates a table in a rich text
item in the document, saves the document, then gets the table and
displays its properties.
%INCLUDE "lsconst.lss"
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Set db = session.CurrentDatabase
REM Create new document with rich text item
Dim doc As New NotesDocument(db)
Call doc.AppendItemValue("From", session.UserName)
Call doc.AppendItemValue("Form", "Main Form")
Call doc.AppendItemValue _
("Subject", Inputbox("Subject?"))
Dim rti As New NotesRichTextItem(doc, "Body")
Call rti.AppendText("Paragraph of text")
Call rti.AddNewLine(2)
REM Create a table
Dim rows As Integer, columns As Integer
rows = 4
columns = 3
Dim tabs() As String
If Messagebox("Do you want a tabbed table?", _
MB_YESNO + MB_ICONQUESTION, "Tabbed?") = IDNO Then
Call rti.AppendTable(rows, columns)
Else
Redim tabs(1 To rows)
For i = 1 To rows
tabs(i) = "Row " & i
Next
Call rti.AppendTable(rows, columns, tabs)
End If
REM Save the document
Call doc.Save(True, False)
REM Get the table
Dim rtnav As NotesRichTextNavigator
Set rtnav = rti.CreateNavigator
If Not rtnav.FindFirstElement(RTELEM_TYPE_TABLE) Then
Messagebox "Could not find table",, "Fatal error"
Exit Sub
End If
Dim rtt As NotesRichTextTable
Set rtt = rtnav.GetElement
labelString = ""
Forall label In rtt.RowLabels
If label <> "" Then labelString = labelString & Chr(13) & _
" " & label
End Forall
If labelString = "" Then labelString = "No labels"
Messagebox "Columns = " & rtt.ColumnCount & Chr(13) & _
"Rows = " & rtt.RowCount & Chr(13) & _
"Labels = " & labelString & Chr(13) & _
Style = " & rtt.Style & Chr(13) & _
"Color = " & rtt.Color.NotesColor & Chr(13) & _
"AlternateColor = " & rtt.AlternateColor.NotesColor _
,, "NotesRichTextTable"
End Sub
- This view action creates a basic auto-width table of 4 rows and
3 columns, and populates it.
Sub Click(Source As Button)
Dim session As New NotesSession
Dim db As NotesDatabase
Set db = session.CurrentDatabase
REM Create document with Body rich text item
Dim doc As New NotesDocument(db)
Call doc.ReplaceItemValue("Form", "Main topic")
Call doc.ReplaceItemValue("Subject", "Table 4 x 3")
Dim body As New NotesRichTextItem(doc, "Body")
REM Create table in Body item
rowCount% = 4
columnCount% = 3
Call body.AppendTable(rowCount%, columnCount%)
REM Populate table
Dim rtnav As NotesRichTextNavigator
Set rtnav = body.CreateNavigator
Call rtnav.FindFirstElement(RTELEM_TYPE_TABLECELL)
For iRow% = 1 To 4 Step 1
For iColumn% = 1 To 3 Step 1
Call body.BeginInsert(rtnav)
Call body.AppendText("Row " & iRow% & ", Column " & iColumn%)
Call body.EndInsert
Call rtnav.FindNextElement(RTELEM_TYPE_TABLECELL)
Next
Next
REM Save document and refresh view
Call doc.Save(True, False)
Dim ws As New NotesUIWorkspace
Call ws.ViewRefresh
End Sub
- This agent gets the cells in the first table in an item and displays
the first text paragraph in each cell.
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
Dim rtrange As NotesRichTextRange
Set rtrange = rti.CreateRange
Call rtnav.FindFirstElement(RTELEM_TYPE_TABLECELL)
firstFlag = True
For i& = 1 To rtt.RowCount
For j& = 1 To rtt.ColumnCount
If Not firstFlag Then
Call rtnav.FindNextElement(RTELEM_TYPE_TABLECELL)
Else
firstFlag = False
End If
Call rtrange.SetBegin(rtnav)
Messagebox rtrange.TextParagraph,, _
"Row " & i& & _
", Column " & j&
Next
Next
End Sub