i ve got a problem using the appendRTitem method after changing the insertion point with begininsert. i am using this script:
[…]
Set rtnav = rt.CreateNavigator
Call rtnav.FindFirstElement(RTELEM_TYPE_TABLE)
'the item/table should be inserted after the first table in the rt-item
Call rt.BeginInsert(rtnav,False)
'insert a table with 2 rows and 2 columns as a test
Call rt.AppendTable(2,2)
'now the richtextitem
Call rt.AppendRTItem(rt2)
Call rt.EndInsert
Call docto.Save(True,True)
-all richtextitems are initialized and set correctly-
Here is my problem:
When i run this script without the line “call rt.appendrtitem(rt2)” it works fine and the table is inserted at the right position.
But running this script without the line “call rt.appendtable(2,2)” an errormessage appears “Method is not available”
As i remove the begininsert method from the script the richtextitem is appended at the end. But i need it somewhere in the middle not at the end.
From these experiences i suppose that appending a RTitem at the end of another item works fine but somehow you cannot edit the insertion point and insert a RTitem.
Even if the Help-Database sais “AppendRTItem method → Inserts the contents of one rich text item in another.”
What might be wrong?
Please tell me your experiences appending / inserting a RTitem into another one.
What I did to insert an RTItem at an arbitrary point (based on a string) in another RTItem, is to make 2 copies of the destination RTITem. Then take the first copy and trim out everything after the insertion point text. Then take the second copy and trim out everything before the insertion point text. Then clear out the original destination RTItem, append the first copy back in, append the RTItem you wanted appended, and append the second copy. You end up with your RTItem inserted at an arbitrary point, without using BeginInsert
something like this:
Sub InsertRTItem( Body As NotesRichTextItem, Tag As String, InsertItem As NotesRichTextItem )
Dim TempDoc As NotesDocument
Dim BeforeTagItem As NotesRichTextItem
Dim AfterTagItem As NotesRichTextItem
Dim TagNav As NotesRichTextNavigator
Dim TagRange As NotesRichTextRange
Set TempDoc = db.CreateDocument
Set BeforeTagItem = Body.CopyItemToDocument( TempDoc, "Temp1" )
Set AfterTagItem = Body.CopyItemToDocument( TempDoc, "Temp2" )
'prepare beforetagitem - remove tag and everything after
Set TagNav = BeforeTagItem.CreateNavigator
Call TagNav.FindFirstString( Tag )
Set TagRange = BeforeTagItem.CreateRange
Call TagRange.SetBegin( TagNav )
Call TagRange.Remove
'prepare aftertagitem - remove everything before the tag
Set TagNav = AfterTagItem.CreateNavigator
Call TagNav.FindFirstString( Tag )
Set TagRange = AfterTagItem.CreateRange
Call TagRange.SetEnd( TagNav )
Call TagRange.Remove
'also remove the tag itself
Call TagRange.SetBegin( TagNav )
Call TagRange.SetEnd( TagNav )
Call TagRange.Remove
'clear body
Set TagRange = Body.CreateRange
Call TagRange.Remove
'insert beforetagitem, insertitem, aftertagitem
Call Body.AppendRTItem( BeforeTagItem )
Call Body.AppendRTItem( InsertItem )
Call Body.AppendRTItem( AfterTagItem )