RichText Felder eines im UI geöffneten Dokumentes im BackEnd modifizieren
Manfred Meise 26 April 2012 20:45:35
Der hierfür notwendige Code könnte z.B. in einer Maskenaktion untergebracht sein:
'(Globals):
Option Public
%INCLUDE "lsprcval.lss"
'Refresh:
Option Declare
Sub Click(Source As Button)
Dim ws As New NotesUIWorkspace
Dim s As New NotesSession
Dim doc As NotesDocument
Dim rtItem As NotesRichTextItem
On Error Goto ErrorBubble
Set doc = ws.CurrentDocument.Document
Set rtItem = doc.GetFirstItem ("Body")
If Not rtItem Is Nothing Then
Call rtItem.AppendText ("Hallo Welt")
Call doc.Save (True, True)
Call RefreshRTF (s, ws)
End If
SingleExit:
Exit Sub
'-----------------------------------------------------------------------------------------------------------------------------------------------------
ErrorBubble:
'Unexpected Error: Bubble up to caller or user
Error Err, Error & Chr(13) & { --> in } & Getthreadinfo (LSI_THREAD_PROC) & { : } & Erl
Resume SingleExit
End Sub
Sub RefreshRTF (s As NotesSession, ws As NotesUIWorkspace)
Dim uidoc As NotesUIDocument
Dim docReload As NotesDocument
Dim strNoteid As String
Dim blnRemoveSaveOptions As Boolean
Dim blnInPreview As Boolean
Dim blnEditMode As Boolean
Const FIELD_SAVEOPTIONS = "SaveOptions"
On Error Goto ErrorBubble
If (s Is Nothing) Or (ws Is Nothing) Then Exit Sub
Set uidoc = ws.CurrentDocument
If uiDoc Is Nothing Then Exit Sub
' preserve current state data
blnInPreview uidoc.InPreviewPane
blnEditMode = uidoc.EditMode
strNoteid = uidoc.Document.noteid
' get this document out of memory
If Not blnInPreview Then
If blnEditMode Then
If Not uidoc.Document.HasItem (FIELD_SAVEOPTIONS) Then blnRemoveSaveOptions = True
Call uidoc.Document.ReplaceitemValue (FIELD_SAVEOPTIONS, "0")
End If
Call uidoc.Close
End If
Delete uidoc
' reload document to it's original state
Set docReload = s.currentdatabase.getdocumentbyid(strNoteid)
If blnRemoveSaveOptions Then
Call docReload.RemoveItem (FIELD_SAVEOPTIONS)
Call docReload.Save(True , False)
End If
If blnInPreview Then
' refresh in place
Delete docReload
Call ws.ReloadWindow
Else
Call ws.EditDocument(blnEditMode, docReload)
End If
SingleExit:
Exit Sub
'-----------------------------------------------------------------------------------------------------------------------------------------------------
ErrorBubble:
'Unexpected Error: Bubble up to caller or user
Error Err, Error & Chr(13) & { --> in } & Getthreadinfo (LSI_THREAD_PROC) & { : } & Erl
Resume SingleExit
End Sub
Zielgruppe: Entwickler Kategorien: LotusScript Richtext Diskussion: Kommentare [0]