HELP NEEDED "Restricted operation cannot cross logical boundaries"

Hi All.

I am removing doclinks from 4 different rtext fields. My script below works pretty well except if it finds a doclink that is contained within a section of a rtext field then it bombs out with the error “Restricted operation cannot cross logical boundaries”

My script is from the help dbase in r6 designer.

Can anyone tell me why the error appears and any idea on how to solve it

The error actually happens on the “rtlink.remove” line of code

Code as Follows


Sub Initialize

' REM this agent loops through the 4 rtext fields of all main docs and removes all doclinks from these fields

'  REM This script is one of several steps to cleanse all rtext fields of attachments, doclinks before all rtext content is pasted into a word doc

Dim session As NotesSession

Dim db As NotesDatabase

Dim doc As NotesDocument

Dim view As notesview

Dim rtitem As NotesRichTextItem

Dim rtnav As NotesRichTextNavigator

Dim temp As String

Set session = New NotesSession

Set db = session.CurrentDatabase

Set view = db.GetView("MainDocs")

Dim DocLinkFound As Boolean

Dim count As Integer

Dim countA As Integer

Dim i As Integer

Dim RTNames(4) As String

RTNames(0) = "refdocs"

RTNames(1) =  "DocDefinition"

RTNames(2) =  "DocProcedure"

RTNames(3) =  "DisplayDocs"

Dim rtlink As NotesRichTextDocLink

Dim rtlink2 As NotesRichTextDocLink

Set doc = view.GetFirstDocument

count = 0



While Not doc Is Nothing

	temp = Doc.Docnumber(0)

	DocLinkFound = False

	For i = 0 To 3

		Set rtitem = doc.GetFirstItem( RTNAMES(i))

		If Not rtitem Is Nothing Then 

			If ( rtitem.Type = RICHTEXT ) Then

				Set rtnav =rtitem.CreateNavigator

			 REM Get doclinks and remove

				If  rtnav.FindFirstElement(RTELEM_TYPE_DOCLINK) Then

					DocLinkFound = True

					Do

						Set rtlink = rtnav.GetElement

						rtlink.Remove

						Count = Count + 1

					Loop While rtnav.FindNextElement		

				End If

			End If

		End If

	Next

	If DocLinkFound Then

		Call doc.Save(True, True)

	End If

	Set doc = view.GetNextDocument(doc)

Wend

Msgbox Cstr(count) & " Doc Links Removed"

End Sub


Hope somebody can help :slight_smile: