LOTUSSCRIPT/COM/OLE CLASSES


Examples: Navigator property
This agent gets every paragraph in every cell in the first table of the current document. The agent works within elements by setting up a navigator for the table and for each cell in the table.

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 rtnavCell As NotesRichTextNavigator
 Dim rtrangeTable As NotesRichTextRange
 Dim rtrangeCell As NotesRichTextRange
 Dim rtrangePara As NotesRichTextRange
 Dim counter As Integer
 Dim msg As String
 Dim rtnavFlag As Boolean
 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
 Set rtrangePara = body.CreateRange
 Call rtnavTable.FindFirstElement(RTELEM_TYPE_TABLECELL)
 Do
   Call rtrangeCell.SetBegin(rtnavTable)
   Call rtrangeCell.SetEnd(rtnavTable)
   Set rtnavCell = rtrangeCell.Navigator
   msg = ""
   counter = counter + 1
   REM Get each paragraph in cell
   REM Set range and its paragraph text
   rtnavFlag = rtnavCell.FindFirstElement(RTELEM_TYPE_TEXTPARAGRAPH)
   If rtnavFlag Then
     Do
       Call rtrangePara.SetBegin(rtnavCell)
       Call rtrangePara.SetEnd(rtnavCell)
       msg = msg & rtrangePara.TextParagraph & Chr(13)
     Loop While rtnavCell.FindNextElement(RTELEM_TYPE_TEXTPARAGRAPH)
   Else
     msg = "<No text paragraph in cell>"
   End If
   Messagebox msg,, "Cell " & counter
 Loop While rtnavTable.FindNextElement(RTELEM_TYPE_TABLECELL)
End Sub