LOTUSSCRIPT /COM/OLE のクラス


例:IsDefault プロパティ
次のエージェントは、ユーザーの入力から文書を作成します。ユーザーは、Body 段落のスタイルを太字または斜体に設定できます。段落の記述が終わると、スタイルがまだデフォルト状態になっていない場合は、コードにより太字と斜体がデフォルト設定に戻されます。

Sub Initialize
 Dim session As New NotesSession
 Dim db As NotesDatabase
 Set db = session.CurrentDatabase
 Dim doc As New NotesDocument(db)
 Call doc.AppendItemValue("From", session.UserName)
 Call doc.AppendItemValue _
 ("Subject", Inputbox("Subject?"))
 Call doc.AppendItemValue _
 ("Categories", Inputbox("Category?"))
 Dim rts As NotesRichTextStyle
 Set rts = session.CreateRichTextStyle
 Dim rti As New NotesRichTextItem(doc, "Body")
 newPara = Inputbox("Enter paragraph of text")
 firstPara = True
 While newPara <> ""
   If firstPara Then
     firstPara = False
   Else
     Call rti.AddNewLine(2)
   End If
   Call SetAttributes(rts)
   Call rti.AppendStyle(rts)
   Call rti.AppendText(newPara)
   If Not rts.IsDefault Then Call ClearAttributes(rts)
   newPara = Inputbox("Enter paragraph of text")
 Wend
 Call doc.Save(True, False)
End Sub

Sub SetAttributes(style As NotesRichTextStyle)
 attribs = Lcase(Inputbox( _
 "Attributes (bold - italic - nobold -  noitalic)?"))
 If Instr(attribs, "bold") <> 0 Then
   style.Bold = True
 End If
 If Instr(attribs, "italic") <> 0 Then
   style.Italic = True
 End If
 If Instr(attribs, "nobold") <> 0 Then
   style.Bold = False
 End If
 If Instr(attribs, "noitalic") <> 0 Then
   style.Italic = False
 End If
End Sub

Sub ClearAttributes(style As NotesRichTextStyle)
 style.Bold = STYLE_NO_CHANGE
 style.Italic = STYLE_NO_CHANGE
End Sub

関連項目