Problem: embedding object / attaching file (LotusScript)

Hello,

I have a problem embedding or attaching a file into an existing field.

The Form contains a field called “Anghangfeld” - this field is RichText.

I try to embed an object or attach a file into this (existing!) field this way:

Dim wsp As New NotesUIWorkspace

Dim uidoc As notesuidocument

Dim doc As notesdocument

Dim db As NotesDatabase

Dim Anhang As NotesEmbeddedObject



Set uidoc = wsp.CurrentDocument

Set doc = uidoc.Document

Set AFIT = doc.GetFirstItem("Anhangfeld")

Set Anhang = AFIT.EmbedObject ( EMBED_ATTACHMENT, "", "c:\motorola_pebl.pdf")



Call doc.Save(True,False,True)

But the Attachment is NOT placed in the exisiting field (Anhangfeld); it is always stored in a $FILE beyond the last line of the document

And: there is not difference if the field “Anhangfeld” is editable or calculated.

Can anyone give me a hint how to solve this problem?

Subject: Problem: embedding object / attaching file (LotusScript)

I think I was to fast in posting the question - I think, I found a way to solve the problem!

Subject: RE: Problem: embedding object / attaching file (LotusScript)

Working with attachments is a PITA. Your RTF might not pick up the attachment correctly if you save the UIdocument right after attaching the file via the backend.

It’s a bit clumsy, but try adding this code after your save call:

doc.SaveOptions = 0

Call uidoc.Close

Call wsp.EditDocument(True, doc)

Subject: RE: Problem: embedding object / attaching file (LotusScript)

Thank you Mike, now it runs perfectly!

Subject: RE: Problem: embedding object / attaching file (LotusScript)

THANK YOU! I’ve been struggling with trying to get an Doc link attachment to work and couldn’t find the solution anywhere. This fixed it.