Script to attach a files to Rt field

Hi… Im having a RT field and a button… wen i clicks the button it have to display all files in C: drive… if i selects files from that… that files have to attch in RT field.

This should be done using script…

using ws.openfiledialog we can select the files…

problem is that to attach the files to Rt field…

waiting for the answers…

Thanks in advance…

Subject: Script to attach a files to Rt field

http://www-12.lotus.com/ldd/doc/domino_notes/6.5.1/help65_designer.nsf/f4b82fbb75e942a6852566ac0037f284/3e65827cd8f90d4085256e00004ab945?OpenDocument

Mr Frunobulax

Subject: RE: Script to attach a files to Rt field

Hi…I tried this already…

But its not attching the file into that field…

correct me where im wrong…

Dim ws As New NotesUIWorkspace

filenames = ws.OpenFileDialog(True, "Select files to be attached",, "c:")

Msgbox filenames(0)



Dim uidoc As notesuidocument

Dim doc As notesdocument

Set uidoc=ws.CurrentDocument

Set doc=uidoc.document



Dim rtitem As NotesRichTextItem

Dim object As NotesEmbeddedObject





Set rtitem = New NotesRichTextItem( doc, "rich" )

Call uidoc.GotoField("rich")

Call  rtitem.EmbedObject 	( EMBED_ATTACHMENT, "", filenames(0))



Call doc.Save(True,False)

Call uidoc.Save

Subject: RE: Script to attach a files to Rt field

Try something like this:

Dim rtitem As NotesRichTextItem

Set rtitem = New NotesRichTextItem( doc, "rich" )

Call rtitem.EmbedObject ( EMBED_ATTACHMENT, "", filenames(0))



Call doc.Save(True,False)	

Call uidoc.Close

Call ws.EditDocument( True, doc )

Frunobulax

Subject: RE: Script to attach a files to Rt field

Hi…Its not working…

Let u suggest any other way…

Subject: RE: Script to attach a files to Rt field

Do NOT save the uidoc after attaching the files and saving the backend doc. rather try this to update your uidoc.

	Call doc.Save(True, False)

	doc.SaveOptions = "0"

	docKey = doc.NoteID

	Call uidoc.Close

	Set doc = db.GetdocumentbyID(docKey)

	Set uidoc = ws.EditDocument(True, doc)

You’ll need to include this in the postopen event of your form as well.

If doc.HasItem(“SaveOptions”) Then Call doc.RemoveItem(“SaveOptions”)

HTH

Patrick

Subject: Script to attach a files to Rt field

Try this out. It should work.

Sub Click(Source As Button)

Dim session As New NotesSession

Dim wks As New NotesUIWorkspace



Dim uidoc As NotesUIDocument

Dim doc As NotesDocument

Dim rtitemA As NotesRichTextItem



Dim object As NotesEmbeddedObject

Set uidoc=wks.CurrentDocument

Set doc=uidoc.Document



filenames = wks.OpenFileDialog(True, "Select files to be attached",, "c:")



Set rtitemA = New NotesRichTextItem( doc, "Test" )



Set object = rtitemA.EmbedObject ( EMBED_ATTACHMENT, "", filenames(0))



Call uidoc.Save

Call uidoc.Refresh

End Sub