Subject: RE: LotusScript: How to set paragraph style for first line in a rich-text field?
Yes, I already know that the the blank line is coming from rti.AppendParagraphStyle rtps. That’s exactly the problem.I have to use AppendParagraphStyle to get the paragraph style I want, but it seems impossible for that method to set the paragraph style for the first line of a rich-text item.
I also had already read the help where it says “You can change the insertion point with BeginInsert and EndInsert.”
That doesn’t help at all.
If I start with a new rich-text item that has no content, BeginInsert breaks the code.
For example, with these lines in an agent:
Set rti=doc.CreateRichTextItem(“Body”)
Dim rtrange As NotesRichTextRange
Set rtrange=rti.CreateRange
rti.BeginInsert rtrange
rti.AppendParagraphStyle rtps
rti.EndInsert
As soon as it reaches BeginInsert, the agent stops running. There are no errors. There are no status-bar messages. It just stops, as if it had reached the end of the code.
I also tried a similar thing using a NotesRichTextNavigator instead of a NotesRichTextRange, but exactly the same problem occurs.
If I add some text to the item first, then the BeginInsert line is OK, but it doesn’t solve my original problem.
For example, with these lines in an agent:
Set rti=doc.CreateRichTextItem(“Body”)
rti.AppendText “-”
Dim rtnav As NotesRichTextNavigator
Set rtnav=rti.CreateNavigator
rtnav.FindFirstElement RTELEM_TYPE_TEXTRUN
rti.BeginInsert rtnav
rti.AppendParagraphStyle rtps
rti.EndInsert
Everything runs normally. The paragraph style gets inserted before the “-”, as instructed by BeginInsert, but it still adds a blank line before the paragraph style.
So as far as I can tell, it is absolutely impossible, using the LotusScript rich-text classes, to set the paragraph style for the first line in a rich-text item.
The best that can be done is setting the paragraph style for the second line and everything after it.
That’s just stupid.