色もそうですが「もうちょっと明るい感じ」と言われて変更しても一発OKになることは稀かも。
そこで NotesColorObject の NotesColor プロパティを使って色の見本表を作ってみました。
NotesColor は 0 から 240 の範囲の数値に色が割り当てられています。
最初の0から15には COLOR_BLACK といった定数もあります。
NotesColor へ数値をセットすると、Red, Green, Blue, Hue(色相), Saturation(彩度), Luminance(明度)の値が変わります。
Sub Initialize
Dim ss As New NotesSession
Dim doc As NotesDocument
Dim color As NotesColorObject
Dim body As NotesRichTextItem
Dim nav As NotesRichTextNavigator
Dim range As NotesRichTextRange
Dim table As NotesRichTextTable
Dim style1 As NotesRichTextStyle
Dim style2 As NotesRichTextStyle
Dim style3 As NotesRichTextStyle
Dim styles() As NotesRichTextParagraphStyle
Dim rows%, columns%, i%
Dim rgb$, hsl$
Set doc = ss.CurrentDatabase.CreateDocument
Set body = New NotesRichTextItem( doc, "Body" )
Set nav = body.CreateNavigator
Set range = body.CreateRange
Set color = ss.CreateColorObject
color.NotesColor = 0
Set style1 = ss.CreateRichTextStyle
style1.FontSize = 1
Set style2 = ss.CreateRichTextStyle
style2.NotesColor = COLOR_BLACK
style2.FontSize = 8
Set style3 = ss.CreateRichTextStyle
style3.NotesFont = FONT_ROMAN
style3.FontSize = 7
rows = 16
columns = 16
Redim styles( columns - 1 )
For i = 0 To columns - 1
Set styles( i ) = ss.CreateRichTextParagraphStyle
styles( i ).LeftMargin = 0
styles( i ).FirstLineLeftMargin = 0
styles( i ).RightMargin = RULER_ONE_INCH * 0.75
Next
body.AppendTable rows, columns, , ,styles
nav.FindFirstElement RTELEM_TYPE_TABLECELL
range.SetBegin nav
range.SetStyle style1
range.SetEnd nav
Do
With color
rgb = .Red & " : " & .Green & " : " & .Blue
hsl = .Hue & " : " & .Saturation & " : " & .Luminance
End With
body.BeginInsert nav
'%REM 'NotesColorが不要ならコメントアウト--ここから
body.AppendStyle style2
body.AppendText color.NotesColor
'%END REM 'NotesColorが不要ならコメントアウト--ここまで
body.AppendStyle style1
body.AppendText( " " )
If color.Luminance < 120 Then
style3.NotesColor = COLOR_WHITE
Else
style3.NotesColor = COLOR_BLACK
End If
body.AppendStyle style3
body.AppendTable 1, 1
body.EndInsert
nav.FindNextElement RTELEM_TYPE_TABLE
Set table = nav.GetElement
table.Style = TABLESTYLE_SOLID
table.SetColor color
nav.FindNextElement RTELEM_TYPE_TABLECELL
'%REM 'RGBとHSLが不要ならコメントアウト--ここから
body.BeginInsert nav
body.AppendText rgb
body.AddNewline 1, False
body.AppendText hsl
body.EndInsert
'%END REM 'RGBとHSLが不要ならコメントアウト--ここまで
color.NotesColor = color.NotesColor + 1
If color.NotesColor > 240 Then Exit Do
Loop While nav.FindNextElement( RTELEM_TYPE_TABLECELL )
'%REM '説明が不要ならコメントアウト--ここから
body.AppendStyle style2
body.AppendText "Line 1 NotesColor"
body.AddNewline 1, False
body.AppendText "Line 2 Red : Green : Blue"
body.AddNewline 1, False
body.AppendText "Line 3 Hue : Saturation : Luminance"
'%END REM '説明が不要ならコメントアウト--ここまで
doc.Form = "Memo"
doc.Subject = "Lotus Notes 色見本"
doc.SendTo = ss.UserName
doc.Send False
End Sub色付けはセルごとに設定できません。そのため外側の表にあるセルの中に入れ子の表を作成して、その表へ色を付けています。おおまかな処理の流れは次のとおりです。
1. 外側の表(16行x16列)を作成します
2. 最初のセルへ移動します
3. 内側の表(1行x1列)を作成します
4. 内側の表へ移動します
5. 内側の表全体に色を設定します
6. 次のセル(内側の表のセル)へ移動します
7. RGB, HSL の値を記入します
8. NotesColor に 1 追加します
9. 次のセルへ移動できる間、3~8を繰り返します
NotesColor の数値、RBGおよびHSLの値、値の説明が不要ならコメントアウトしてください
NotesColor の数値を表示しない場合でも表がつぶれず色が見やすくなるようスペース文字を追加してフォントサイズで高さを調整しています。
R,G,BとH,S,Lのそれぞれの値は0から256までの数値です。これを16進表現にしたい場合は Hex 関数で変換できます。
rgb = Hex$(.Red) & " : " & Hex$(.Green) & " : " & Hex$(.Blue)
hsl = Hex$(.Hue) & " : " & Hex$(.Saturation) & " : " & Hex$(.Luminance)
AppendTable で styles を省略して16行16列の表を作成しようとすると「列の幅が不正です - 左余白と右余白を確認してください」が表示され終了してしまいました。
(Notes 8.0.1 Basic版で確認)
0 件のコメント:
コメントを投稿