Hi all,
Hope somebody can help me.
I’m trying to add rows to a table in a rich text field without success.
This field - called History - is not in a table in the form (although it is inside a section).
When the doc is created, the code runs fine, creating the table with one line, one row and the text inside the cell. The problem happens when I edit the same document and try to save the change in the history field. It seems that Notes does not “see” the table anymore (the message “No table” is displayed)
If someone can help me, it would be great. The code is below.
TIA,
Renan.
Sub Queryclose(Source As Notesuidocument, Continue As Variant)
If msg <> “” Then
Dim doc_back As NotesDocument
Set doc_back = Source.Document
Call GenerateTable(doc_back)
End If
End Sub
Globals myForm ’ Sub declared in the Globals
Sub GenerateTable(doc As NotesDocument)
Dim rtnav As NotesRichTextNavigator
Dim rtt As NotesRichTextTable
Dim rtitem As NotesRichTextItem
Dim history As String
Dim dateStr As String
Dim cnUser As String
Dim abbUser As Variant
dateStr = Format(Now, “mm-dd-yyyy”)
cnUser = doc.UserName(0)
abbUser = Evaluate(|@Name([Abbreviate]; “| + cnUser +|”)|)
If msg = “New Document” Then
history = "Document created on " + dateStr + Space(2) + "by " + abbUser(0)
Set rtitem = doc.GetFirstItem(“History”)
Call rtitem.AppendTable(1, 1)
Set rtnav = rtitem.CreateNavigator
Call rtnav.FindFirstElement(RTELEM_TYPE_TABLECELL)
Call rtitem.BeginInsert(rtnav)
Call rtitem.AppendText(history)
Call rtitem.EndInsert
Call doc.Save(True, False)
Exit Sub
Else
history = "Review on " + dateStr + " by " + abbUser(0)
End If
Set rtitem = doc.GetFirstItem(“History”)
Set rtnav = rtitem.CreateNavigator
Call rtnav.FindFirstElement(RTELEM_TYPE_TABLE)
If Not rtnav.FindFirstElement(RTELEM_TYPE_TABLE) Then
Messagebox “No table”
Exit Sub
End If
Set rtt = rtnav.GetElement
Call rtt.AddRow
Call rtnav.FindNextElement(RTELEM_TYPE_CELL)
Call rtitem.BeginInsert(rtnav)
Call rtitem.AppendText(history)
Call rtitem.EndInsert
Call doc.Save(True, False)
End Sub