I have read some previous posts on this, as well as a LOT of help information, but I can’t figure this one out.
All I want to do is have a button that appends the contents of one Rich Text field (“Latestcom”) into another RT field (“history”) on the same document. Here’s the code I’m using:
Sub Click(Source As Button)
Dim ws As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Dim lcom As Variant
Dim hist As Variant
Set uidoc = ws.CurrentDocument
Set doc = uidoc.Document
Set lcom = doc.GetFirstItem("Latestcom")
Set hist = doc.GetFirstItem("history")
Call hist.AppendRTItem(lcom)
End Sub
But I get Object Variable Not Set when I click the button.
any ideas? thanks
Subject: Copying an RT Field into another
All I want to do is have a button that appends the contents of one Rich Text field (“Latestcom”) into another RT field (“history”) on the same document.
That won’t work if the document is open in edit mode and you are using the Background NotesDocument object.
When a document is being edited, the UI version of the RTF is not kept in sync with the version in the Notes Document, and when the UI document is saved, it’s RTF’s replace those stored in the document.
So when you execute <Call hist.AppendRTItem(lcom)> you are updating the RFT in the document, which won’t be displayed in the UIDoc, and the UIDoc version will overwrite your changes as it’s saved.
So there are 2 ways to do this.
Wait until the UI Document is closed by the user, and then update the Document
Update the UI field rather than the Document field by
Moving the cursor to the LastestCom field
Selecting all text
Copying it to the clipboard
Moving the cursor to the history field
Pasting in the clipboard
Subject: Turn on the debugger and see which line causes the problem?
Subject: RE: Turn on the debugger and see which line causes the problem?
Also, declare lcom and hist as NotesRichTextItems, not variants. And remember that you’ll have to close and reopen the document before any rich text item changes through LotusScript take effect.
Subject: Example
’ these statements declare the variables Dim session As New notessession
Dim db As notesdatabase
Dim docA As notesdocument
'Dim docB As New notesdocument(db)
Dim collection As notesdocumentcollection
Dim iteme As notesitem
' these statements assign an object reference to the variables
Set db = session.currentdatabase
Set collection = db.unprocesseddocuments
Set docA = collection.getfirstdocument
Set iteme = docA.getfirstitem("body")
Set docb = New notesdocument(db)
Call iteme.copyitemtodocument(docb, "body")
Call docB.save (True, True)