It seems that the navagator methods do not work when a table is created dynamically into a computed RT field. Once I changed the field properties in the RT field in question, re-opened and saved the document the navigator started working with this simple code.
Sub Click(Source As Button)
Dim ws As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Dim rti As NotesRichTextItem
Dim rtnav As NotesRichTextNavigator
Dim content As Variant
Set uidoc = ws.CurrentDocument
Set doc = uidoc.Document
Set rti = doc.GetFirstItem("BodyTable")
Set rtnav = rti.CreateNavigator
If Not rtnav.FindFirstElement(RTELEM_TYPE_TABLE) Then
Messagebox("body does not contain a table.")
Exit Sub
End If
Dim rtrange As NotesRichTextRange
Set rtrange = rti.CreateRange
Call rtnav.FindNthElement(RTELEM_TYPE_TABLECELL,7)
Call rtrange.SetBegin(rtnav)
content = rtrange.TextParagraph
Messagebox(content)
End Sub
Before I manually saved the document I recieved the message that body does not contain a table. I really want this table created in a computed field so no further editiing can be done. Any suggestions?
Subject: NotesRichTextNavigator - Computed Body Field - One Answer!
A fact that I failed to provide in the first post is the formula in the RT computed field is the RT field name itself. If you add a uidoc.Save before attempting to navigate to the table element, it will be found. The code below works.
Sub Click(Source As Button)
Dim ws As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Dim rti As NotesRichTextItem
Dim rtnav As NotesRichTextNavigator
Dim content As Variant
Set uidoc = ws.CurrentDocument
Set doc = uidoc.Document
Set rti = doc.GetFirstItem(“BodyTable”)
Set rtnav = rti.CreateNavigator If Not
uidoc.Save
rtnav.FindFirstElement(RTELEM_TYPE_TABLE) Then
Messagebox(“body does not contain a table.”)
Exit Sub
End If Dim rtrange As NotesRichTextRange
Set rtrange = rti.CreateRange
Call rtnav.FindNthElemen(RTELEM_TYPE_TABLECELL,7)
Call rtrange.SetBegin(rtnav) content = rtrange.TextParagraph Messagebox(content)
End Sub
Is thier a better way to do this?
Subject: Try NotesUIDocument.Refresh(True) … to include RichTextItems. Might work.
Subject: *More likely to crash your client.
Subject: I would not know, however it fixed a couple of RT problems I had once.
Subject: NotesRichTextNavigator - Computed Body Field - BUG?
Haven’t heard of this, but there’s a known issue that if a rich text field appears inside of a table on the form, you can’t find tables in that field using a NotesRichTextNavigator. If you move the RTF from the table and re-save the document, you should be able to find the tables in the RTF. Could it be that this is what’s messing you up?