NotesRichTexItem:在现有的RTF数据中的第一个位置插入文本字符串 [英] NotesRichTexItem : Insert text strings at the first position in existing rich text data

查看:200
本文介绍了NotesRichTexItem:在现有的RTF数据中的第一个位置插入文本字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'd like to insert the text string into the existing rich text field data at the first position for all of documents in a DB. NotesRichTextNavigator.FindFirstElement method - This method needs to specify the element type to search but I simply insert the text at the first position of the rich text data. This might be very basic question, but I could not find the way and waste a few hours... Please help me!

推荐答案

您可以使用解决方法来做到这一点.无需使用FindFirstElement,而是创建一个虚拟的richtextitem,其中包含您需要在原始项目之前添加的文本, 将原始项目添加到虚拟项目,删除原始项目并重新创建. 然后添加虚拟项目并删除虚拟项目.

You can do this using a workaround. Instead of working with FindFirstElement, you create a dummy richtextitem, containing the text that you need to prepend to your original item, add the original item to the dummy item, delete the original item and recreate it. Then add the dummy item and delete the dummy.

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

This sounds complex, but it is not that hard actually. Here's a small example in LotusScript on how to do this on a document:

    '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)

这篇关于NotesRichTexItem:在现有的RTF数据中的第一个位置插入文本字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆