Examples: AddTab method

  1. This script adds some text, two tabs, and more text to a rich text item called ProjectDescription.
    Dim doc As NotesDocument
    Dim rtitem As Variant
    '...set value of doc...
    Set rtitem = doc.GetFirstItem( "ProjectDescription" )
    If ( rtitem.Type = RICHTEXT ) Then
      Call rtitem.AppendText( "Before" )
      Call rtitem.AddTab( 2 )
      Call rtitem.AppendText( "After" )
      Call doc.Save( False, True )
    End If

    If the ProjectDescription item is empty when the script begins, it looks like this when the script finishes:

    Before After

  2. This script uses AddTab, AddNewLine, and AppendText to create a tabbed "table" of values in a new rich text item called ProductListing. The values are retrieved from the Products view in another database, sourceDb. The first column value is a string; the second is a number, so it's converted to a string before being appended.
    Dim targetDoc As NotesDocument
    Dim targetRTItem As NotesRichTextItem
    '...set value of targetDoc...
    Set targetRTItem = New NotesRichTextItem _
    ( targetDoc, "ProductListing" )
    Dim sourceDb As NotesDatabase
    Dim sourceView As NotesView
    Dim sourceDoc As NotesDocument
    Set sourceDb = New NotesDatabase( "Belem", "inventry.nsf" )
    Set sourceView = sourceDb.GetView( "Products" )
    Set sourceDoc = sourceView.GetFirstDocument
    While Not ( sourceDoc Is Nothing )
      a = sourceDoc.ColumnValues( 0 )
      b = sourceDoc.ColumnValues( 1 )
      Call targetRTItem.AppendText( a )
      Call targetRTItem.AddTab( 1 )
      Call targetRTItem.AppendText( Str( b ) )
      Call targetRTItem.AddNewLine( 1 )
      Set sourceDoc = sourceView.GetNextDocument( sourceDoc )
    Call targetDoc.Save( False, True )

    For example, if the Products view in INVENTORY.NSF has product names in the first column and quantities in the second, the result in the ProductListing item might look like this:

    Nails, common #08 989

    Nails, common #10 1000

    Nails, common #12 1000

    Nails, common #16 978

    Screws, slot, 1/4x2 1000