Sunday 6 March 2011

Append text to Richtext field

This allows you to post a number of text fields into a single RT field.  We use this to send information from a number of fields in a memo document.

You pass in the RTField, the title you want to display, the fieldname of the contents and the doc.  The result is something along the lines of ...



FieldTitle1:  Here are the contents

Obviously we loop this through all of the fields we require.

Sub AppendTextToBody(ritem As NotesRichTextItem, title As String, fieldname As String, doc As NotesDocument)
Dim session As New NotesSession
Dim rstyle As NotesRichTextStyle
Set rstyle=session.CreateRichTextStyle
Dim v As Variant

rstyle.Bold=True
rstyle.NotesColor=COLOR_BLUE
rstyle.FontSize=10
Call  ritem.AppendStyle(rstyle)
Call ritem.AppendText(title)
Call ritem.AddNewLine( 1 )

rstyle.Bold=False
rstyle.NotesColor=COLOR_BLACK
rstyle.FontSize=10
Call  ritem.AppendStyle(rstyle)
v = doc.GetItemValue( fieldname)
ForAll x In V
Call ritem.AppendText(x)
End ForAll

Call ritem.AddNewLine( 2 )
End Sub

No comments:

Post a Comment