.
HCLSoftware Business Partner
Domino Consulting Services
CRUCIAL Notes Tools
+1
212-599-2048
Domino Consulting Services
CRUCIAL Notes Tools
Domino administration
Notes development
Chat now
.
EN - English
CN - 中文
JP - 日本語
DE - Deutsch
FR - Français
BR - Português
RU - Pу́сский
IT - Italiano
IN - हिन्दी
ES - Español
KR - 한국어
ID - Indonesia
NL - Dutch
TR - Türkçe
SA - العربية
SE - Svenska
NO - Norsk
PL - Polski
TH - ไทย
DK - Dansk
MY - Malay
PH - Filipino
GR - Ελληνικά
FI - Suomi
IL - עברית
IE - Gaeilge
CZ - Čeština
UA - Українська
RO - Română
VN - Tiếng Việt
BD - বাংলা
HU - Magyar
Need a Domino Consultant? Call NotesMail +1 212-599-2048
-
HCLSoftware Business Partner
LOTUSSCRIPT/COM/OLE CLASSES
Examples: FindAndReplace method
1. This agent replaces all occurrences of a string that matches user input in the Body item of the current or first selected document.
Sub Initialize
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
Set body = doc.GetFirstItem("Body")
Set rtnav = body.CreateNavigator
searchString$ = Inputbox$ _
("Enter the search string", "Search string")
If searchString$ = "" Then Exit Sub
replaceString$ = Inputbox _
("Enter the replacement string", "Replacement string")
If replaceString$ = "" Then Exit Sub
Call rtnav.FindFirstElement(RTELEM_TYPE_TEXTPARAGRAPH)
Set rtrange = body.CreateRange
count& = rtrange.FindAndReplace _
(searchString$, replaceString$, _
RT_REPL_ALL + RT_FIND_CASEINSENSITIVE)
If count& > 0 Then
Call body.Compact
Call doc.Save(True, True)
End If
Messagebox count& & " replacements made",, count&
End Sub
2. This agent also replaces all occurrences of a string that matches user input in the Body item of the current or first selected document. It uses a loop which is less efficient than RT_REPL_ALL but allows additional coding on a per-iteration basis.
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
Sub Initialize
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
Set body = doc.GetFirstItem("Body")
Set rtnav = body.CreateNavigator
searchString$ = Inputbox$ _
("Enter the search string", "Search string")
If searchString$ = "" Then Exit Sub
replaceString$ = Inputbox _
("Enter the replacement string", "Replacement string")
If replaceString$ = "" Then Exit Sub
Call rtnav.FindFirstElement(RTELEM_TYPE_TEXTPARAGRAPH)
n% = 0
Set rtrange = body.CreateRange
While rtrange.FindAndReplace _
(searchString$, replaceString$, RT_FIND_CASEINSENSITIVE) > 0
n% = n% + 1
Messagebox "Replacement " & n%,, n%
Call body.Update ' Must update before looping
Wend
If n% > 0 Then
Call body.Compact
Call doc.Save(True, True)
End If End Sub
Feedback on
Help
or
Product Usability
?
Help on Help
All Help Contents
Feedback on
Help
or
Usability
?
Help on Help
All Help Contents