Dynamic table not getting added

Below code is present on the postopen event of form. It is supposed to load the table of two rows with the headings in the first row. Heading are as mentioned in the code.But this does not create the table.

Also the table should be created only when the document is new…

Any suggestion??

Dim ws As New NotesUIWorkspace

Dim uidoc As NotesUIDocument

Dim doc As NotesDocument

Dim rti As NotesRichTextItem

Dim rtnav As NotesRichTextNavigator

Dim rtt As NotesRichTextTable

Dim richStyle As NotesRichTextStyle

Dim sess As New NotesSession



Set uidoc=ws.CurrentDocument

Set doc=uidoc.Document

Set rti=doc.GetFirstItem("MeetingAgenda")

If rti Is Nothing Then

        Set rti = doc.CreateRichTextItem("MeetingAgenda")

End If

Set rtnav = rti.CreateNavigator

Set richStyle = sess.CreateRichTextStyle



Call rti.AppendTable( 1, 3)

Call rtnav.FindFirstElement(RTELEM_TYPE_TABLE)

Set rtt = rtnav.GetElement

richStyle.Bold = True

richStyle.FontSize = 9

Call rti.AppendStyle(richStyle)



Call rtnav.FindNextElement(RTELEM_TYPE_TABLECELL)

Call rti.BeginInsert(rtnav)

Call rti.AppendText("Item #")		

Call rti.EndInsert

Call rtnav.FindNextElement(RTELEM_TYPE_TABLECELL)



Call rti.BeginInsert(rtnav)

Call rti.AppendText("Topic")		

Call rti.EndInsert

Call rtnav.FindNextElement(RTELEM_TYPE_TABLECELL)



Call rti.BeginInsert(rtnav)

Call rti.AppendText("Timing")		

Call rti.EndInsert

Call rtnav.FindNextElement(RTELEM_TYPE_TABLECELL)



richStyle.Bold = False

Call rti.AppendStyle(richStyle)

Call rtt.AddRow(1)

Call uidoc.Save()

Call uidoc.Close()

Subject: Dynamic table not getting added.

You are closing the document in the postopen itself. Ideally the changes made to the richtext items are visible in the uidoc only after closing the document and reopening it.

For you a better solution will be to write your own script for composing the new document. You can create a Notesdocument in the script add rich text field and table in it, then save the document and open the document object in edit mode by calling Notesuiworkspace method EditDocument.

Aniz

Subject: Dynamic table not getting added.

Hey!! Thanks…It worked…