次のエージェントは、リッチテキストアイテム内の各要素の範囲プロパティを表示します。これらの要素はタイプ別の順序で取得されています。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
Set rtrange = body.CreateRange
Call DisplayRange(RTELEM_TYPE_TEXTPARAGRAPH, _
"Text paragraph")
Call DisplayRange(RTELEM_TYPE_TEXTRUN, _
"Text run")
Call DisplayRange(RTELEM_TYPE_DOCLINK, _
"Doc link")
Call DisplayRange(RTELEM_TYPE_FILEATTACHMENT, _
"File attachment")
Call DisplayRange(RTELEM_TYPE_OLE, _
"OLE object")
Call DisplayRange(RTELEM_TYPE_SECTION, _
"Section")
Call DisplayRange(RTELEM_TYPE_TABLE, _
"Table")
Call DisplayRange(RTELEM_TYPE_TABLECELL, _
"Table cell")
End Sub
Sub DisplayRange(elemType As Integer, elemTypeStr)
If rtnav.FindFirstElement(elemType) Then
count% = 0
Do
count% = count% + 1
Call rtrange.SetBegin(rtnav)
If elemType = RTELEM_TYPE_TABLECELL Or _
elemType = RTELEM_TYPE_TEXTPARAGRAPH Or _
elemType = RTELEM_TYPE_TEXTRUN Then
Messagebox _
"Type: " & rtrange.Type & Chr(13) & _
"Text run: " & rtrange.TextRun & Chr(13) & _
"Text paragraph: " & rtrange.TextParagraph _
,, elemTypeStr & " " & count%
Else
Messagebox _
"Type: " & rtrange.Type & Chr(13) _
,, elemTypeStr & " " & count%
End If
Loop While rtnav.FindNextElement(elemType)
Else
Messagebox "No element of this type in Body",, _
"No " & elemTypeStr
End If
End Sub