We help IT Professionals succeed at work.
Get Started

NotesRichTextNavigators, NotesRichTextRanges and NotesRichTextSections

devguru001 asked
Last Modified: 2013-12-18

So I have an interesting problem. Here is the scenario. We have a helpdesk db where sometimes it's required to contact the user, keeping them up to date or whatever the reason may be. So from the helpdesk I would create a new memo. This memo would contain whatever you want to ask or tell the user and at the end of the email there is a section called "---------------------------------------------------------------------------------------History---------------------------------------------------------------------------------------". This section contains all of the correspondence between the helpdesk and the user. The history is copied from a response document (called a summary document) connected to the specific helpdesk call that basically contains all of the correspondence. This history section is a section that contains other sections. See image below. So I need to, after the email has been sent, to delete the history section and add the current correspondence back into the helpdesk. Reason for deleting the history is because that history is stored in a summary document so we only need the latest correspondence.

Problem is when I want to navigate to the history section and setting the range and all and then delete everything from the history downward, Notes just doesn't delete the history section too. It deletes anything AFTER the history section but not the history section INCLUDED.

Here is some sample code that I was playing around with but no joy. Your assistance in this will be GREATLY appreciated.


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 rts As NotesRichTextSection
      Dim rtrangesec As NotesRichTextRange
      Dim rtt As NotesRichTextTable
      Dim count As Integer
      Dim strtitle As String
      Set uidoc = ws.CurrentDocument
      Set doc = uidoc.Document
      If uidoc.EditMode Then
            uidoc.EditMode = False
      End If
      Set rti = doc.GetFirstItem("Body")
      Set rtnav = rti.CreateNavigator
      strtitle = "---------------------------------------------------------------------------------------History---------------------------------------------------------------------------------------"
      If rtnav.FindFirstElement(RTELEM_TYPE_SECTION) Then
            Count = 0
            Set rts = rtNav.GetFirstElement(RTELEM_TYPE_SECTION)
            If RTS Is Nothing Then
                  Messagebox("Did not get first section")
            End If
            While Not  rts  Is Nothing            
                  Count = count + 1
                  If RTS.Title = STRTitle Then
                        Set rtrange = rti.CreateRange
                        If RTNav.FindNthElement(RTELEM_TYPE_SECTION, count) Then                        
                              Call RTNav.SetPositionAtEnd(RTNav)            
                              Call rtrange.SetBegin(rtnav)                        
                              Call rtrange.Remove                              
                              Set RTS = Nothing
                        End If
                        Set rts = rtNav.GetNextElement(RTELEM_TYPE_SECTION)            
                  End If
      End If
      Call doc.Save(True, True)

End Sub
Watch Question
Groupware Consultant
This problem has been solved!
Unlock 1 Answer and 7 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE