例: GetFormattedText method

  1. 次のスクリプトは、文書の Body アイテムを取得し、属性のないテキストファイル PLANE.TXT にその内容を書き込みます。ファイル内の既存のテキストに上書きします。テキストはタブを保持し、デフォルトの行折り返しが使用されます。
    Dim doc As NotesDocument
    Dim rtitem As Variant
    Dim plainText As String
    Dim fileNum As Integer
    '...set value of doc...
    Set rtitem = doc.GetFirstItem( "Body" )
    If ( rtitem.Type = RICHTEXT ) Then
      plainText = rtitem.GetFormattedText( False, 0 )
    End If
    ' get a file number for the file
    fileNum = Freefile
    ' open the file for writing
    Open "c:¥plane.txt" For Output As fileNum
    ' write the formatted text to the file
    Print #fileNum, plainText
    ' close the file
    Close #fileNum
  2. 次のスクリプトは、文書の Body アイテムを取得し、属性のないテキストファイル .PLANE.TXT にその内容を追加します。ファイル内の既存のテキストは維持されます。追加されたテキストは、タブが取り除かれ、15 文字ごとに折り返されます。
    Dim doc As NotesDocument
    Dim rtitem As Variant
    Dim plainText As String
    Dim fileNum As Integer
    '...set value of doc...
    Set rtitem = doc.GetFirstItem( "Body" )
    If ( rtitem.Type = RICHTEXT ) Then
      plainText = rtitem.GetFormattedText( True, 15 )
    End If
    ' get a file number for the file
    fileNum = Freefile
    ' open the file for appending
    Open "c:¥plane.txt" For Append As fileNum
    ' write the formatted text to the file
    Print #fileNum, plainText
    ' close the file
    Close #fileNum