LOTUSSCRIPT/COM/OLE CLASSES


Examples: Clone method
This agent gets the first two paragraphs in the Body item of the current document. The agent finds the first paragraph with one navigator, clones it, and finds the second paragraph with the cloned navigator.

Sub Initialize
 Dim session As New NotesSession
 Dim db As NotesDatabase
 Dim dc As NotesDocumentCollection
 Dim doc As NotesDocument
 Dim body As NotesRichTextItem
 Dim rtnavBody1 As NotesRichTextNavigator
 Dim rtnavBody2 As NotesRichTextNavigator
 Dim rtrangePara As NotesRichTextRange
 Set db = session.CurrentDatabase
 Set dc = db.UnprocessedDocuments
 Set doc = dc.GetFirstDocument
 Set body = doc.GetFirstItem("Body")
 REM Set navigator to first paragraph in Body item
 Set rtnavBody1 = body.CreateNavigator
 If Not rtnavBody1.FindFirstElement(RTELEM_TYPE_TEXTPARAGRAPH) Then
   Messagebox "Body item does not contain text,",, "Error"
   Exit Sub
 End If
 REM Set cloned navigator to second paragraph in Body item
 Set rtnavBody2 = rtnavBody1.Clone
 If Not rtnavBody2.FindNextElement(RTELEM_TYPE_TEXTPARAGRAPH) Then
   Messagebox "Body item does not contain two paragraphs,",, "Error"
   Exit Sub
 End If
 REM Get first and second paragraphs
 Set rtrangePara = body.CreateRange
 Call rtrangePara.SetBegin(rtnavBody1)
 Messagebox rtrangePara.TextParagraph,, "First paragraph"
 Call rtrangePara.SetBegin(rtnavBody2)
 Messagebox rtrangePara.TextParagraph,, "Second paragraph"
End Sub

See Also