Help: How to get handle to all the attachements without saving a document

Hi

I have got a problem for which i need help

I am trying to get handle to all the attachments in a document without saving it.But the code which I am using to do this gives me Error: “object variable not set”.Please help me in this regard…

Dim ses As New NotesSession

Dim ws As New NotesUIWorkspace

Dim db As NotesDatabase

Set db=ses.CurrentDatabase

Dim uidoc As NotesUIDocument

Dim doc As NotesDocument

Dim rtitem As Variant

Dim fileCount As Integer

Dim objectA As NotesEmbeddedObject

Dim rtitemA As NotesRichTextItem

Dim ArchDoc As NotesDocument

Set uidoc=ws.CurrentDocument

Set doc=uidoc.Document

Msgbox(doc.HasEmbedded)

If doc.HasEmbedded Then

fileCount = 0 

Msgbox(fileCount)	

'…set value of doc…

Set rtitem = doc.GetFirstItem( “TestAttach” )

If ( rtitem.Type = RICHTEXT) Then

Forall o In rtitem.EmbeddedObjects

If ( o.Type = EMBED_ATTACHMENT )Then

Msgbox(o.Name)

fileCount = fileCount + 1

Call o.ExtractFile( "c:\temp"& Cstr(o.Name))

Set ArchDoc = New NotesDocument( db )ArchDoc.form=“frmAttachments”

Set rtitema = New NotesRichTextItem(ArchDoc, “Body” )

Set objectA= rtitemA.EmbedObject( EMBED_ATTACHMENT, “”, "c:\temp" & Cstr(o.Name))

ArchDoc.VendorName=doc.VName(0)

AttachmentReferanceNo=Evaluate(“@unique”)

ArchDoc.UniqueID=AttachmentReferanceNo(0)

Call ArchDoc.Save(True,False)

Call o.Remove

Call doc.Save( True, True )

End If

End Forall

End If

End If

Call uidoc.Refresh

Call uidoc.Save

Call uidoc.Close

Subject: * Read about NotesUIDocument.Refresh