I’ve been working on trying to retrieve all the text within one particular titled section which is contained within a rich text field. I was able to code an agent to retrieve the first paragraph of text from the first section within the rtf - but that’s not enough. These docs are from an old documentation database from which we need to retrieve certain content which is always in a section with a consistent title. I need to make sure I have the right section and that I get all the content not just the first paragraph of that section. Scouring Notes Designer help and borrowing code from here and there I put together an agent which addressed the first requirement (identifying the correct section)
Unfortunately I have not been able to figure out how to get ALL the text paragraphs in the Section once I find it.
Sub Initialize
Dim session As NotesSession
Dim db As NotesDatabase
Dim dc As NotesDocumentCollection
Dim doc As NotesDocument
Dim body As NotesRichTextItem
Dim rtnav As NotesRichTextNavigator
Dim rtrange As NotesRichTextRange
Set session = New NotesSession
Set db = session.CurrentDatabase
Set dc = db.UnprocessedDocuments
If dc.Count = 0 Then
Messagebox "No document selected",, "No doc"
Exit Sub
End If
Set doc = dc.GetFirstDocument
Do While Not (doc Is Nothing)
If Ucase(doc.Appl_Type(0)) = "BATCH" Then
Goto nextdoc
End If
Set body = doc.GetFirstItem("c_descript")
Set rtnav = body.CreateNavigator
foundit = False
If rtnav.FindFirstElement(RTELEM_TYPE_SECTION) Then
Dim rts As NotesRichTextSection
Do
Set rts = rtnav.GetElement <-- Notes crashes if debugger is on
'Msgbox rts.Title
If rts.Title = "Short description of application" Then
foundit = True
Goto exitloop
End If
Loop While rtnav.FindNextElement(RTELEM_TYPE_SECTION, 1)
exitloop:
If foundit Then
Set rtrange = body.CreateRange
Call rtrange.SetBegin(rtnav)
doc.TextDesc = rtrange.TextParagraph
Call doc.Save(False,False)
End If
End If
nextdoc:
Set doc = dc.GetNextDocument(doc)
Loop
End Sub
I’m hoping someone can help me figure out how to get ALL the text in the section I find, not just the first paragraph.