Attaching a file in a richtext field

I am trying to attach a file to a notes document using an action hotspot.

My code is working, with the exception that my file is not be attached in my richtext field, but rather at the bottom of the document.

I read the following thread of a person having the same issue, and Andre responding linking to a thread about refreshing the uidoc w/out saving it…

http://www-10.lotus.com/ldd/nd6forum.nsf/55c38d716d632d9b8525689b005ba1c0/96c392f64f9da4fb85256f2e004e4507?OpenDocument

The author of the thread said he would try the solution, but never responded if it worked…

As it isn’t working for me.

Here is my code:

Sub Click(Source As Button)

Dim session As New NotesSession

Dim db As NotesDatabase

Dim workspace As New NotesUIWorkspace

Dim uiDoc As NotesuiDocument

Dim uiDocNew As NotesUiDocument

Dim doc As NotesDocument

Dim filenames As Variant

Dim rtitem As NotesRichTextItem

Dim object As NotesEmbeddedObject



Set db = session.CurrentDatabase

Set uiDoc = workspace.CurrentDocument

Set doc = uiDoc.Document



filenames = workSpace.OpenFileDialog(True, "Select files LOE documents.")

If Not(Isempty(filenames)) Then

	Set rtitem = doc.GetFirstItem("LOEAttachment")

	Forall filename In filenames

		

		Set object = rtitem.EmbedObject( EMBED_ATTACHMENT, "", filename)

	End Forall

End If

Call updateHistory(session, doc," attached LOE documents. ", "")



doc.SaveOptions = "0" 

Call uidoc.Close(True) 

Set uidocNew = workspace.EditDocument(True, doc, , , , True)

Set uidoc = workspace.currentdocument	

End Sub

Has anyone been successful attaching a file in a richtext field using LotusScript?

Many thanks for any help.

Subject: Attaching a file in a richtext field

Any reason why you can’t use formula?

I use this all the time:

@Command([EditGotoField];“FileName”);

@Command([EditInsertFileAttachment])

Or to automate in LS:

Dim ric As NotesRichTextItem

Dim EmbedObj As NotesEmbeddedObject

Set ric = doc.CreateRichTextItem("WordDoc")

Set EmbedObj = ric.EMBEDOBJECT(1454, "", _ FileName,"Attachment")

Where FileName is something like “c:\something.txt”

Subject: RE: Attaching a file in a richtext field

i have a strange requirement, the attachee (person attaching the file) can’t see the richtext field where file is to be attached…

So, I can’t really use formula language, since attachee would have to first goto the field and then do the attachment stuff

I’ll try the other…

But , is something wrong w/prompting user for the file name…

shouldn’t that work…

Subject: Attaching a file in a richtext field

I received an email from Andre, I needed to add call uidoc.upload after attaching the file. Then all is well…

Thanks!

Dim session As New NotesSession

Dim db As NotesDatabase

Dim workspace As New NotesUIWorkspace

Dim uiDoc As NotesuiDocument

Dim uiDocNew As NotesUiDocument

Dim doc As NotesDocument

Dim filenames As Variant

Dim rtitem As NotesRichTextItem

Dim object As NotesEmbeddedObject Set db = session.CurrentDatabase

Set uiDoc = workspace.CurrentDocument

Set doc = uiDoc.Document filenames = workSpace.OpenFileDialog(True, "Select

files LOE documents.")

If Not(Isempty(filenames)) Then

Set rtitem = doc.GetFirstItem(“LOEAttachment”)

Forall filename In filenames Set object = rtitem.EmbedObject( EMBED_ATTACHMENT,

“”, filename)

'new code - added this one line… now working

call uidoc.update

'end new code

End Forall

End If

Call updateHistory(session, doc," attached LOE documents. doc.SaveOptions = “0”

Call uidoc.Close(True)

Set uidocNew = workspace.EditDocument(True, doc, , , , True)