Examples: NotesRichTextItem class

5. The EmbeddedObects property returns EMPTY if there are no embedded objects. For example:

  1. This script creates a new rich text item called ProjectDescription and adds a text value to it.
    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. This script achieves the same result as the preceding one, but also copies the newly created rich text item to a second document. Because NotesRichTextItem inherits from NotesItem, the rtitem object can use methods defined in both NotesRichTextItem (such as AppendText) and NotesItem (such as 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. This script creates a new NotesRichTextItem called "Body" on a mail memo. It uses the AppendDocLink method to place a doclink to the current document in the Body, and the Send method to mail the memo to 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. This script gets an existing rich text item called ProjectDescription and adds a carriage return and a text value to it. Notice how rtitem is declared a variant, since the GetFirstItem method returns a NotesItem that may or may not be a NotesRichTextItem. Since Type is a property defined in NotesItem, you can use it with a NotesRichTextItem as well. The script tests the variant to see if it is rich text; if so, it uses NotesRichTextItem methods on the variant. For more information, see the GetFirstItem method in NotesDocument.
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 )

5. The EmbeddedObects property returns EMPTY if there are no embedded objects. For example:

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