Invalid or nonexistent document on object.ExtractFile

Hi folks,

I’m running into a strange problem with Embedded Objects, and I’m hoping

somebody can point me at the obvious thing to fix. Here’s the scenario:

On my form, docTempAttach is a global variable (NotesDocument). It was created

in the back end during QueryOpen, and has NOT been saved. It has a rich text

item, Attachments, in it (Created with LS) with a number of attachments that

were put there using RTItem.AppendRTItem.

In my code, I do the following (Full code available if you need it)

Set vAttachments = docTempAttach.GetFirstItem( “Attachments” )

Forall o In vAttachments.EmbeddedObjects

If o.Name = sName Then

'Attach the old version to the version control document

sFileName = "c:\notes\" & sName

Call o.ExtractFile( sFileName )

Call rtHistory.EmbedObject( EMBED_ATTACHMENT, "", "c:\notes\" + sName, 

sName )

End If

End Forall

I think it looks about right, but I’m getting an error "Invalid or nonexistent

document (c:\notes\filename.xls)" on the ExtractFile call.

Script debugger tells me that o exists, and has type 1454 like it should. The

directory exists, and is empty.

Am I missing something really obvious here? I’m about to start frothing at the

mouth.

-Brendan

Subject: Invalid or nonexistent document on object.ExtractFile

I think you’ll find that you have to save the NotesDocument at least once before you can access the embedded objects. This is because various features and updates to a RichTextfield are not set/ ‘visible’ until the document is saved.

Subject: RE: Invalid or nonexistent document on object.ExtractFile

Yep, I think you’re right. I tried using another rich text field in a saved document and it all works fine.

I suspected this might be the case, but I saw that the embedded objects all existed in the script debugger and I got my hopes up.

Thanks for the response!