Hallöchen,
ich nutze die FindAndReplace-Funktion des NotesRichTextRange-Objekts und habe jetzt folgendes Problem: Ich möchte einen gesuchten Text in einen Text mit Umbrüchen erstetzten. Der komplette Text wird auch ausgetauscht, nur werden die Umbrüche (egal ob Chr(10) oder Chr(13)) gelöscht.
Hier ein Beispielagent:
Sub Initialize
Dim db As NotesDatabase
Dim dc As NotesDocumentCollection
Dim doc As NotesDocument
Dim lng_result As Long
Dim rti As NotesRichTextItem
Dim s As NotesSession
Dim str_replace As String
Dim str_search As String
Set s = New NotesSession
Set db = s.CurrentDatabase
Set dc = db.UnprocessedDocuments
Set doc = dc.GetFirstDocument
str_search = "Test"
str_replace = "T" & Chr(10) & _
"e" & Chr(10) & _
"s" & Chr(10) & _
"t"
Do Until doc Is Nothing
Set rti = doc.GetFirstItem("Body")
lng_result = RTIFindAndReplace(rti, str_search, str_replace)
If lng_result > 0 Then
Print lng_result & " gesucht, gefunden und geändert"
Call doc.Save(True, False)
End If
Set doc = dc.GetNextDocument(doc)
Loop
End Sub
Public Function RTIFindAndReplace(rti_source As NotesRichTextItem, str_search As String, str_replace As String) As Long
Dim rtn As NotesRichTextNavigator
Dim rtr As NotesRichTextRange
Dim lng_result As Long
Set rtn = rti_source.CreateNavigator
Call rtn.FindFirstElement(RTELEM_TYPE_TEXTPARAGRAPH)
Set rtr = rti_source.CreateRange
lng_result = rtr.FindAndReplace(str_search, str_replace, RT_REPL_ALL + RT_FIND_CASEINSENSITIVE)
If lng_result > 0 Then Call rti_source.Compact
RTIFindAndReplace = lng_result
End Function
Die Umbrüche sind nach dem Durchlauf nicht da.
Hat jemand eine Idee?
Danke im Voraus