Examples: Remove method (NotesRichTextRange - LotusScript®)
This agent removes the content of every cell in the first table of 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 rtnavTable As NotesRichTextNavigator
Dim rtrangeTable As NotesRichTextRange
Dim rtrangeCell As NotesRichTextRange
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 and navigator 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)
Set rtnavTable = rtrangeTable.Navigator
REM Get each cell in table
REM Set range and navigator for it
Set rtrangeCell = body.CreateRange
Call rtnavTable.FindFirstElement(RTELEM_TYPE_TABLECELL)
Do
Call rtrangeCell.SetBegin(rtnavTable)
Call rtrangeCell.SetEnd(rtnavTable)
Call rtrangeCell.Remove
Call doc.Save(True, True, True)
Loop While rtnavTable.FindNextElement(RTELEM_TYPE_TABLECELL)
End Sub