I am trying to write a simple function to move the value of one rich text field to another. This function is triggered through a button on the form.
I noticed that while the code runs without any error, my second Rich text field do not show the content of the first field. It’s valuelenght show 104B but the value remains empty, How can I make this code work?
Thanks in advance.
Below is my code
+++++++++++++++++++++++++++++++
Sub Click(Source As Button)
Dim session As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim rtitem1 As Variant
Dim rtitem2 As Variant
Dim ws As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Set uidoc = ws.CurrentDocument
Set doc=uidoc.Document
Set rtitem1 = doc.GetFirstItem( "SAS_Strategic_Direction" )
If Not rtitem1 Is Nothing Then
Set rtitem2 = doc.GetFirstItem( "WKSAS_Strategic_Direction" )
If rtitem2 Is Nothing Then
Set rtitem2 = New NotesRichTextItem ( doc, "SAS_Strategic_Direction" )
End If
If ( rtitem1.Type = RICHTEXT And _
rtitem2.Type = RICHTEXT ) Then
Call rtitem1.AppendRTItem( rtitem2)
doc.SaveOptions = "0"
Call doc.Save(False, True)
End If
End If
Subject: RE: Help Copying Rich Text from field to another?
Yes, SaveOptions = “0” prevents the document from being saved. The whole point of this code is to close and reopen the document without saving changes. After we reopen the document from the data in memory which includes your rich text changes, we do uidocNew.Document.RemoveItem(“SaveOptions”) so that the document will save normally when the user tries to save it.
I don’t understand your comment about rtitem. We don’t have to save it to a field because it is the field.
Please just try it, many people have used it and it works.