例: NotesRichTextItem class

埋め込みオブジェクトが含まれていない場合は、EmbeddedObects プロパティは EMPTY を返します。以下に例を示します。

  1. 次のスクリプトはリッチテキストアイテム ProjectDescription を新規に作成して、テキスト値を追加します。
    Dim doc As NotesDocument
    Dim rtitem As NotesRichTextItem
    '...set value of doc...
    Set rtitem = New NotesRichTextItem _
    ( doc, "ProjectDescription" )
    Call rtitem.AppendText _
    ( "Cartoon book for children ages 9-12" )
    Call doc.Save( False, True )
  2. 次のスクリプトの実行結果は上記のスクリプトと同じです。ただし、新規作成されたリッチテキストアイテムを 2 番目の文書にコピーします。NotesRichTextItem は NotesItem を継承しているため、rtitem オブジェクトは NotesRichTextItem で定義されているメソッド (AppendText など) と NotesItem で定義されているメソッド (CopyItemToDocument など) の両方を使用できます。
    Dim docA As NotesDocument
    Dim docB As NotesDocument
    Dim rtitem As NotesRichTextItem
    '...set values of docA and docB...
    Set rtitem = New NotesRichTextItem _
    ( docA, "ProjectDescription" )
    Call rtitem.AppendText _
    ( "Cartoon book for children ages 9-12" )
    Call rtitem.CopyItemToDocument( docB, "" )
    Call docA.Save( False, True )
    Call docB.Save( False, True )
  3. 次のスクリプトは「Body」という名前の新しい NotesRichTextItem をメールメモ上に作成します。このスクリプトは、AppendDocLink メソッドを使用して現在の文書への文書リンクを「Body」に配置します。また、Send メソッドを使用してメモを Frank Glennel にメールで送信します。
    Dim session As New NotesSession
    Dim db As NotesDatabase
    Dim memo As NotesDocument
    Dim rtitem As NotesRichTextItem
    Set db = session.CurrentDatabase
    '...set value of doc...
    Set memo = New NotesDocument( db )
    Set rtitem = New NotesRichTextItem( memo, "Body" )
    Call rtitem.AppendDocLink( doc, db.Title )
    memo.Subject = "Here's a link to the document"
    Call memo.Send( False, "Frank Glennel" )
  4. 次のスクリプトは、既存のリッチテキストアイテム ProjectDescription を取得し、改行とテキスト値を追加します。なお、rtitem が Variant 型で宣言される方法に注意してください。これは、GetFirstItem メソッドが、NotesRichTextItem であるかどうか分からない NotesItem を返すためです。Type は NotesItem で定義されたプロパティであるため、NotesRichTextItem でも使用できます。スクリプトは Variant 型変数がリッチテキストかどうかを調べます。リッチテキストであれば、スクリプトは Variant 型変数で NotesRichTextItem メソッドを使用します。詳しくは NotesDocument の GetFirstItem メソッドを参照してください。
Dim doc As NotesDocument
Dim rtitem As Variant
'...set value of doc...
Set rtitem = doc.GetFirstItem( "ProjectDescription" )
If rtitem.Type = RICHTEXT Then
  Call rtitem.AddNewLine( 1 )
  Call rtitem.AppendText _
  ( "Book is 64 pages, full color." )
End If
Call doc.Save( False, True )

埋め込みオブジェクトが含まれていない場合は、EmbeddedObects プロパティは EMPTY を返します。以下に例を示します。

Dim doc As NotesDocument
Dim rtitem As Variant 
'...set value of doc... 
Set rtitem = doc.GetFirstItem( "Body" )
If ( rtitem.Type = RICHTEXT ) Then  
If Not Isempty(rtitem.EmbeddedObjects) Then    
Forall o In rtitem.EmbeddedObjects      
If ( o.Type = EMBED_ATTACHMENT ) Then        
Call o.ExtractFile( "c:¥samples¥" & o.Source )        
Call o.Remove        Call doc.Save( False, True )      
End If    
End Forall  
End If 
End If