rtLib — Notes Rich Text Management Library Documentation of rtLib — Notes Rich Text Management Library Download rtLib — Notes Rich Text Management Library FAQ of rtLib — Notes Rich Text Management Library Purchase rtLib — Notes Rich Text Management Library Feedback about rtLib — Notes Rich Text Management Library

Building and managing rich text

Working with rtItem

Start search Mail feedback Back to Description

Available starting with version 1.3 rtItem represents the rich text item in document. It can either be manipulated by few direct methods or you can use Container method to obtain corresponding rtContainer object and proceed as before.

Dim rti as rtItem

set rti = new rtItem (doc, "Body") ' we now have retrieved rich text from body to rtItem object

' we can either use direct manipulations

rti.replace "MS", "IBM", 0,0,0,0 ' see parameter description in class help

rti.update ' update rich text item

doc.save true, true ' save document

' or we can retrieve Container

Dim ctx as rtContainer, table as rtTable

Set ctx = rti.Container

set table = ctx.getFirstElement(RT_OBJ_TABLE) ' retrieve 1st table

....

ctx.ReplaceItemValue doc, "Body" ' update item -- here we have an option to save to any other item

ctx.ReplaceItemValue doc, "History" ' this will work as well; it will write rich text we retrieved from "Body" and modified to item "History"

At the moment modifications in rtItem directly does not show up in Container and other way round. However this will change in version 2, so to have a forward compatible code manipulate either via one or other and call update before accessing data via other property. Example:

Dim rti as rtItem, ctx as rtContainer

set rti = new rtItem (doc, "Input") ' we now have retrieved rich text from field "Input"

rti.replace "MS", "IBM", RT_REPLACE_ALL,0,0,0

rti.update ' update rich text item

' after update we can retrieve Container - it will contain the new content

Set ctx = rti.Container

ctx.addNewLine 1 ' one more line

ctx.appendText "Modified: " &Cstr(now)

call ctx.replaceItemValue (doc, "Input")

' now item is again updated, we can get it from rtItem again

rti.refresh ' get updates

rti.exportRTF "exportfile.rtf" ' and export the new content to MS RTF