NotesRichTexItem:在现有富格文本数据的第一个位置插入文本字符串



我想在DB中所有文档的第一个位置将文本字符串插入到现有的富文本字段数据中。备注RichTextNavigator。FindFirstElement方法-这个方法需要指定要搜索的元素类型,但我只是在富文本数据的第一个位置插入文本。这可能是一个非常基本的问题,但我找不到路,浪费了几个小时。。。请帮帮我!

您可以使用变通方法来完成此操作。您不使用FindFirstElement,而是创建一个伪richtextitem,其中包含需要在原始项前添加的文本,将原始项目添加到伪项目中,删除原始项目并重新创建。然后添加伪项并删除伪项。

这听起来很复杂,但实际上并没有那么难。下面是LotusScript中关于如何在文档上执行此操作的一个小示例:

'Get your richtext field
Set rtf = doc.getfirstItem("myRTF")
'create the dummy
Set rtDummy = doc.Createrichtextitem("rtfDummy")
'set the text that you want to insert in your richtext field
Call rtDummy.appendText("Inserting a line of text at the top")
'Add a line to make sure the inserted text is on a separate paragraph
Call rtDummy.Addnewline(1, true)
'Add the content of the original richtext item
Call rtDummy.Appendrtitem(rtf)
'Remove the original item and recreate it
Call rtf.Remove()
Set rtf = doc.Createrichtextitem("myRTF")
'Append the dummy item (including the added text)
Call rtf.Appendrtitem(rtDummy)
'Remove the dummy item
Call rtDummy.Remove()
'Save the document
Call doc.Save(True, True)

相关内容

最新更新