次のコードは、フロントエンドの文書を閉じて開きます。これにより Queryclose、Queryopen、Postopen などのフォームイベントが起動するため注意が必要です。また、uidoc.Refresh は計算結果フィールドと入力確認式も起動します。このため、@IsDocBeingSaved または @IsDocBeingSent が true でないかぎり確認式が @Failure を返さないように作成してください。Dim wksp As New NotesUIWorkspace
Dim session As New NotesSession
Dim uidoc As NotesUIDocument, uidocNew As NotesUIDocument
Dim doc As NotesDocument
Dim rti As NotesRichTextItem
Dim strFieldname As String
Set uidoc = wksp.CurrentDocument
uidoc.Refresh True ' if user may have modified the rich text field
Set doc = uidoc.Document ' get the back-end document
strFieldname = uidoc.CurrentField ' remember the current field if any
Set rti = doc.GetFirstItem("fieldname") ' put fieldname here e.g. "Body"
' Make your rich text changes here, for instance:
Call rti.AddNewLine(1, True)
Call rti.AppendText(Now & ": log entry.")
If session.NotesBuildVersion >= 190 Then
rti.Update ' ND6 only
Else
Call doc.ComputeWithForm(True, False)
' caution may erase field values if @Db functions in formulas
End If
doc.SaveOptions = "0"
' to close document without "do you want to save" prompt
' for mail-in doc, may need to set MailOptions="0
Call uidoc.Close(True)
Set uidocNew = wksp.EditDocument(True, doc, , , , True)
Delete uidoc
uidocNew.Document.RemoveItem("SaveOptions")
If strFieldname <> "" Then uidocNew.GotoField(strFieldname)
' return focus to field that was current before