Problem Copying RichText Item

Hello;I am creating a document(uicon) using another document(currentdoc). I take some fields from currentdoc and set them in uicon using an agent.I have a field named DM_PieceJointeSolution which is of type ‘Richtext’,i have to take whatever is there and put it in the CNS_PieceJointeSolution field.

Earlier i used to do it like >>>See snippet of codes.

Set currentdoc=uidoc.document

Set uicon = ws.ComposeDocument(nomserverconn,nombaseconn,"CNS",,,True)	

Set docconn=uicon.Document



docconn.SaveOptions="1"



Call uicon.FieldSetText("Doc_EDP", ensemble)			

Call uicon.FieldSetText("Classeur",classeur)



Call uidoc.GoToField( "DM_PieceJointeSolution" )

Call uidoc.SelectAll

Call uidoc.Copy

Call uicon.GoToField( "CNS_PieceJointeSolution" )

Call uicon.Paste



Call uicon.Refresh

Call uicon.Save

But then the user complained that if he make a ‘print screen’ or copy something before using the agent, whatever he has copied get pasted in the “CNS_PieceJointeSolution” instead of what is in the “DM_PieceJointeSolution”!!!

So I thought of changing the code to this:

Dim rtitemA As Variant

Dim rtitemB As Variant

Set rtitemA = currentdoc.GetFirstItem( “DM_PieceJointeSolution” )

Set rtitemB = docconn.GetFirstItem( “CNS_PieceJointeSolution” )

If ( rtitemA.Type = RICHTEXT And rtitemB.Type = RICHTEXT ) Then

Call rtitemB.AppendRTItem( rtitemA )

end if

Now its not doing anything!!!Whether it has smething in “DM_PieceJointeSolution” or not,it just doesnt do anything.

Can please someone tell me how to do this???

Thanks.

Subject: Problem Copying RichText Item

Your second code is the right approach, but you need to note that rich-text items may not be accessible until you have done a save. Also, “If ( rtitemA.Type = RICHTEXT And rtitemB.Type = RICHTEXT )” will always fail unless rtitemB has already been populated.

If the doc can’t be saved immediately before the code you have written, then you should do an “artificial” save (set SaveOptions = “0”, save it, then get it back), something like this

Set note = uidoc.Document

	note.SaveOptions = "0" 

	Call uidoc.Close(True)

	Set uidocNew = ws.EditDocument(True, note, , , , True)

Hope this helps