I have a requirement where there is a document which has an attachment and when I click on a button, it opens a new form. This form must have that attachment in the rich text field. I have written the below code in the PostOpen event of the new form that opens up
Set item1= tardoc.GetFirstItem("Comments")
Set item= sourcedoc.GetFirstItem("Current_US")
If Not item Is Nothing Then
If item.Type = RICHTEXT Then
Set rtitem = item
If Not Isempty(rtitem.EmbeddedObjects) Then
Forall fileItem In rtitem.EmbeddedObjects
If fileItem.Type = EMBED_ATTACHMENT Then
Call fileItem.ExtractFile(filepath _
& Cstr(fileItem.Name))
attFile = filepath & Cstr(fileItem.Name)
Call item1.EmbedObject( EMBED_ATTACHMENT, "", attFile)
End If
End Forall
End If
End If
End If
The sourcedoc is the doc from where the attachment has to be copied and the tardoc is the doc to which the attachment has to be copied and it is also the new document that opens up, so in the postopen event of this form I have written the code. But at this line the code fails saying object variable not set. Call item1.EmbedObject( EMBED_ATTACHMENT, "", attFile)