Jerry Manner 28.Mar.12 09:51 AM a Web browser Applications Development7.0.3Windows XP
Hi
I am using the code below to update an opened notes document with an attachment in a richtext field. When making a selection in a dialog list field a richtext field is populated with an attachment that comes from a config document. problem is that the atachment is not actually placed in the richtext field but at the bottom of the document.
What am I missing in my code:
==============================
Dim uidoc As NotesUIDocument
Dim CurDb As NotesDatabase
Dim doc As NotesDocument
Dim s As New notessession
Dim ws As New NotesUIWorkspace
Dim rtitem1 As NotesRichTextItem
Dim rtitem2 As NotesRichTextItem
Dim DocTypevw As notesview
Dim DocTypedoc As notesdocument
Set CurDb = s.CurrentDatabase
Set uidoc = ws.CurrentDocument
Set doc = uidoc.Document
Set DocTypevw = CurDb.GetView("LkpDocumentType")
Set rtitem1 = doc.GetFirstItem("TemplateBody")
If rtitem1 Is Nothing Then
Set rtitem1 = New NotesRichTextItem ( doc, "TemplateBody" )
End If
If Trim(uidoc.FieldGetText("DocumentType")) <> "" Then
Set DocTypedoc = DocTypevw.GetDocumentByKey(uidoc.FieldGetText("DocumentType"))
Set rtitem2 = DocTypedoc.GetFirstItem("Template")
Call rtitem1.AppendRTItem( rtitem2 )
If Cstr(Trim(uidoc.FieldGetText("DocumentType"))) <> Cstr(Trim(uidoc.FieldGetText("TempDocumentType"))) Then
Call RecreateDoclinkRT(uidoc, doc, rtitem1)
End If
End If
Sub RecreateDoclinkRT(ProUIdoc As NotesUIDocument, Prodoc As NotesDocument, WIRTItem1 As NotesRichTextItem)
%REM
code below is to update the richtext field on the Resource Planning tab that contains all doclinks of the Project Work Instruction
%END REM
Dim ws As New NotesUIWorkspace
Dim uidocNew As NotesUIDocument
WIRTItem1.Update ' update the changed richtext field
Projectdoc.SaveOptions = "0" ' make it possible to close the document without a "do you want to save" prompt. If this is a mail-in doc you may need to set MailOptions="0" also to avoid being prompted.
'Call Projectdoc.Save(True, True)
Call ProjectUIdoc.save()
Call ProjectUIdoc.Close(True)
Set uidocNew = ws.EditDocument(True, Projectdoc, , , , True)
Call uidocNew.FieldSetText("SaveOptions","1")
'Call uidocNew.FieldSetText("$ProjectT","Resource Planning")
'uidocNew.Document.~$ProjectT = "Resource Planning"
Delete ProjectUIdoc
uidocNew.Document.RemoveItem("SaveOptions")
' If strFieldname <> "" Then uidocNew.GotoField(strFieldname)
End Sub
==============================