Help Copying Rich Text from field to another?

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

)

Call uidoc.RefreshHideFormulas

Call uidoc.Refresh

End Sub

Subject: Help Copying Rich Text from field to another?

Update rich text tip

Subject: RE: Help Copying Rich Text from field to another?

Adrea, doesnt the doc.saveoption=“0” also stop changes from being saved?

Subject: RE: Help Copying Rich Text from field to another?

For sure it does, and because of that, current changes to RT items are never reflected in the DOM. And that’s not what you want.

Subject: RE: Help Copying Rich Text from field to another?

Harkpabst

I am looking at Andre’s code, he has SaveOptions =0 as well. Also I dont see where he reassignes back rtitem to any fields.

Am I missing something?

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.

  • Andre Guirard, IBM/Lotus Development

Useful blog: Best Practice Makes Perfect

For faster answers, be C R I S P Y

Subject: RE: Help Copying Rich Text from field to another?

Good old times, when we used to have a link to the forum FAQ in the navigation on the right …

Subject: RE: Help Copying Rich Text from field to another?

in the meanwhile…:slight_smile:

http://www-10.lotus.com/ldd/nd6forum.nsf/Resources/ForumFAQs?OpenDocument

Subject: RE: Help Copying Rich Text from field to another?

Forum FAQ…Another broken links?

It’s been almost a month now…

Date

Topic

Knowledge base - Broken - I’m a freak (JY Riverin)

JYR