Detach Attachment files

I have a view and in the “View Action” button I am trying this code… When I select a document in the view and press the action button, it should detach all the attachment files from the Body field from the selected document.

I get an error “Object variable not set” ?? CAn somebody tell me why?? (This is the code from the designer Help)

CODE:

Dim doc As NotesDocument

Dim rtitem As Variant

Dim fileCount As Integer

fileCount = 0

'…set value of doc…

Set rtitem = doc.GetFirstItem( “Body” )

If ( rtitem.Type = RICHTEXT ) Then

Forall o In rtitem.EmbeddedObjects

If ( o.Type = EMBED_ATTACHMENT ) Then

fileCount = fileCount + 1

Call o.ExtractFile( "c:" & Cstr(fileCount) )

Call o.Remove

Call doc.Save( False, True )

End If

End Forall

End If

Subject: Detach Attachment files

Try setting the doc value :slight_smile:

'…set value of doc…

Subject: RE: Detach Attachment files

How do I get handle to the highlighted document in the view?Suppose my cursor is on the nth document in the view?

Subject: RE: Detach Attachment files

Look at NotesUIView.CaretNoteID.

Subject: RE: Detach Attachment files

I got it working with uiview.Documents

thanks all.

Subject: RE: Detach Attachment files

That code is available here: http://www-10.lotus.com/ldd/sandbox.nsf/ecc552f1ab6e46e4852568a90055c4cd/fe7542cd3b120e1b00256c38004a6a27?OpenDocument&Highlight=0,detach

It work very well.

Subject: Detach Attachment files

are you setting the document ?

above code is given only as an example.No document is initialized.

Subject: Detach Attachment files

on which line are you getting the error? post ALL of your code.