Clone a Document

Hi,

I have a view where i have a Clone button. When user selects the document and clicks on Clone, a clone document should be created. The problem here is i have a rich text field. I dont want the attachments in the Main document to come into the clone document. I want to remove them. Its working fine for the code i have written. But if the main document does not have any attachments, on click of clone button i am getting Type Mismatch.

Here the code for removal of attchments.

Dim rt1 As NotesRichTextItem

	Set rt1=engdoc.getfirstitem("attachment")		

	Forall o In rt1.embeddedobjects 

		If o.type=EMBED_ATTACHMENT Then 

			Call o.remove

		End If

	End Forall

I am getting Type Mismatch at below statement for documents without attachments.

Forall o In rt1.embeddedobjects

Can anyone tell me the turn around for this.

Thanks in Advance

Subject: Clone a Document

Hi,

Here is a short LS code for removing all files from a document.

result = Evaluate({@AttachmentNames}, wdoc )

For attachcount = 0 To Ubound(result)

filename = result(attachcount)

If filename <> “” Then

Set o = wdoc.GetAttachment(filename)

If Not o Is Nothing Then

o.Remove

End If

End If

Next

It is bullet proof.

++ Czk.

Subject: Clone a Document

Try this …If not (rt1.embeddedobjects is Nothing) then

Forall o In rt1.embeddedobjects

HTH