Hi,
I have been trying to write a quick agent that will create a table in a RichTextField and poulate it with data on the fly. I have been successful in creating the table however, when I try and poulate the table I am getting some strange results. When I use the method FindNextElement(RTELEM_TYPE_TABLECELL), it appears to be jumping a couple of cells. Looking into it further it appears to class 2 cells as a single element so when I jump from the first element to the next element it then pastes the value into column 3 rather than the second column. Can anyone see where the code is going wrong???
Help!
DC
The code I am using is:
Dim session As New NotesSession
Dim db As NotesDatabase
Dim iRow As Integer, iColumn As Integer
Dim rows As Integer, columns As Integer
On Error Goto errorOut
Set db = session.CurrentDatabase
REM Create new document with rich text item
Dim doc As New NotesDocument(db)
Call doc.ReplaceItemValue("Form", "Main Form")
Dim rti As New NotesRichTextItem(doc, "Body")
REM Create a table
rows = 1
columns = 4
Call rti.AppendTable(rows, columns)
REM Save the document
Dim body As New NotesRichTextItem(doc, "Body")
REM Get the table
Dim rtnav As NotesRichTextNavigator
Set rtnav = rti.CreateNavigator
If Not rtnav.FindFirstElement(RTELEM_TYPE_TABLE) Then
Messagebox "Could not find table",, "Fatal error"
Exit Sub
End If
' Populate the table
Call rtnav.FindFirstElement(RTELEM_TYPE_TABLECELL)
iRow = 1
For iColumn = 1 To 4
Call body.BeginInsert(rtnav)
Call body.AppendText("Row " & iRow & ", Column " & iColumn)
Call body.EndInsert
Call rtnav.FindNextElement(RTELEM_TYPE_TABLECELL)
Next
Call doc.Save(True, False)
Exit Sub
errorOut:
Messagebox Error$ & " (Line: " & Trim(Str(Erl)) & ") "
Exit Sub