Attaching embedded objects to a Rich Text field

Hi,

I want to extract an embedded object from a RT item in a document and then attach it to another item in another document. All the examples in this regard create a new RT item and then call the EmbedObject method. How do I embed it in an existing RT field? I tried the following piece of code but it didn’t work :

Set rt_source = doc_source.GetFirstItem(“Title”)

Set rt_dest = doc_dest.GetFirstItem(“Subject”)

Forall emb_obj in rt_source.EmbeddedObjects

Call emb_obj.ExtractFile("C:"& emb_obj.source)

Set emb_obj2 = rt_dest.EmbedObject(emb_obj.Type,“”,"C:"& emb_obj.source)

Kill "C:"& emb_obj.source

End Forall

It fouls up in the call to EmbedObject … The error is “Object Variable Not Set” This error doesn’t happen if I replace the statement

Set rt_dest = doc_dest.GetFirstItem(“Subject”)

with

Set rt_dest = doc_dest.CreateRichTextItem(“Sub”)

What am I doing wrong?

Subject: You can only extract file attachments, not embedded objects …

from the help :

Copies a file attachment to disk.

Call notesEmbeddedObject.ExtractFile( path$ )

Parameters

path$

String. The path and file name where you want to store the extracted file on disk.

Usage

For embedded objects and object links, this method raises an error.