Hi everybody,
I’m having problems to replace a substring inside a rich text field called BODY. This works normally. The problem appears when my field BODY exists several times in a DOC.
I don’t know if I could explain, so in another words, my document properties (at Notes Client) shows me that the document has more than one field called BODY (probably because the field is too large, that the Notes broke the information in two or more pieces, using the same field name).
I’m trying to access the second piece of information, but I’m not having success. Normally, after I run my code, the document ALWAYS lose the extras-fields of BODY. The document stays with only ONE field (losing all the rest of information).
Anyone know how can I replace a substring inside multi-field (the same field broken in many pieces)?
Thanks a lot!
My code is:
Sub Initialize
On Error Goto ErrorHandler
Dim ss As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim doc As NotesDocument
Dim buffer As String
Dim array As Variant
Dim i As Integer
Dim y As Integer
Set db = ss.CurrentDatabase
Set view = db.GetView("vdoc")
Set doc = view.GetFirstDocument
i = 0
While Not doc Is Nothing
If doc.HasItem("Body") Then
buffer = ""
array = doc.GetItemValue("Body")
y = 0
Forall x In array
buffer = DSStringReplaceSubstring(Cstr(x), "filesdc01", "qualitaalias")
array(y) = buffer
y = y + 1
End Forall
Call doc.ReplaceItemValue("Body", array)
Call doc.Save(True, False)
End If
i = i + 1
Print "Checked: " & Cstr(i)
Set doc = view.GetNextDocument(doc)
Wend
Exit Sub
ErrorHandler:
Msgbox "Error: " & Err() & ": " & Error() & " na linha " & Erl()
End Sub