Go Premium for a chance to win a PS4. Enter to Win

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1249
  • Last Modified:

Indent Paragraph Code for LotusScript

I have been having trouble locating some code for adding a RichText Field.AppendText for an indented paragraph. In Notes itself it would be using the F8 key.  Is there some way to do that with AppendText or AppendStyle?  Some sample code would be helpful. Thanks.
  • 5
  • 4
1 Solution
Have you tried with right margin property of RTParagraphStyle (example from Designer help):
This example sets the right margin property of a rich text paragraph style object.
    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", "Meeting agenda")
    Dim rtpStyle As NotesrichTextParagraphStyle
    Set rtpStyle = session.CreateRichTextParagraphStyle
    Dim richText As New NotesRichTextItem(doc, "Body")
    rtpStyle.RightMargin = RULER_ONE_INCH
    Call richText.AppendParagraphStyle(rtpStyle)
    Call richText.AppendText("Where are we now?")
    Call richText.AddNewLine(1)
    Call richText.AppendText (" Where do we go from here?")
    Call doc.Save(True, False)

Open in new window

donnamlambAuthor Commented:
I guess I don't understand how the RightMargin method would produce a paragraph indented from the original margins of an email.  I'm trying to start with the original margin, then indent a whole paragraph to highlight it, and then return the rest of the email to its original margins.  Will the code snippiet you provided do that for me? The RightMargin method would seem to move the right margin in (or to the left) one inch as per your code snippet.  What would that do to the left margin?  And, then, how would I return later to the email's original margins?

Sorry to be "thick" on this, but I'm new to programming for Lotus Notes, even though I've been a programmer in other languages for several years.


This is NotesRichTextParagraphStyle, not NotesEMailMessageTemplateStyle :)

Indentation you want is exactly what I suggested.
It only affects current paragraph (see NotesRichTextNavigator in Designer help to navigate to exact paragraph you want changed).

And it wont do anything to the left margin.
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

It's not margin like in Word, in Notes, every paragraph has its margin.
To test this manually, while in a mail body, right click on text and select "Text properties". Then go to third (paragraph margins) tab.
donnamlambAuthor Commented:
I tried the code you sent. First of all, since I'm writing this code inside of Microsoft Access, it doesn't know what "RULER_ONE_INCH" means. It thinks it's an undefined variable.  I went to the IBM site and looked it up, and it mentioned a number 1440 (for the number of twips in one inch), however it doesn't give me an equivalent code that VBA would understand.  For instance, a color of Blue is 4. Is there an equivalent for that similar to color numbers?

I tried experimenting with various numbers that I could substitute for the RULER_ONE_INCH constant, and the emails I was producing put all of the characters in each AppendText line all against the left margin in a vertical  position like:


Any other suggestions?  I really appreciate your trying to help me.
To set: notesRichTextParagraphStyle.RightMargin = margin

The following constants are available:
     RULER_ONE_INCH (1440)

The unit of measure used by the above constants is a "twip," where one centimeter is 567 twips and one inch is 1440 twips. You can apply arithmetic to the constants to obtain other measurements. For example, RULER_ONE_CENTIMETER * 2 for two centimeters or RULER_ONE_INCH * 0.75 for three-quarters of an inch.

Post the code (you should've said it for OLE)...
donnamlambAuthor Commented:
Sorry I didn't reply to your last post, mbonaci, I was away from the office for a few days.  I'm back now, but won't get back to this until tomorrow (Wednesday).  Thanks for your patience.

donnamlambAuthor Commented:
mbonaci, sorry for the delay in getting back to you.  I have attached a sample of the code I'm trying to use. As stated before, I'm trying to format an indented paragraph from the original margins.  However, the attached code snippet doesn't appear to do anything.  I lost the code that was putting everything in a vertical line like I sent earlier.  This code produces the following:

Beginning paragraph at regular margin.

Indented Paragraph by 1/2 inch.

Ending paragraph back at original margin.

All paragraphs starting at the same spot.  Can you point me in the right direction?  Again, I'm using Microsoft Access to send draft emails via Lotus Notes.


Sub CreateMail()
Const EMBED_ATTACHMENT As Integer = 1454
    Const EMBED_OBJECT As Integer = 1453
    Const EMBED_OBJECTLINK As Integer = 1452
    Const RULER_ONE_INCH As Integer = 1440
    Dim S As Object ' use back end classes to obtain mail database name
    Dim db As Object '
    Dim memo As Object 'new document
    Dim RTField As Object
    Dim rtpStyle As Object
    Dim networkid, directory As String
    Call CreateNotesSession&
    networkid = fOSUserName()
    directory = "mail1\" + networkid
    Set S = CreateObject("Notes.Notessession") 'create notes session
    Set db = S.GETDATABASE("", directory)
    Set memo = db.CreateDocument
    memo.SendTo = "donna@yahoo.com"
    Set RTField = memo.CREATERICHTEXTITEM("Body")
    Set rtpStyle = S.CreateRichTextParagraphStyle
    Call RTField.AppendText("" & "Beginning paragraph at regular margin.")
    Call RTField.AppendText("" & vbCrLf & vbCrLf)
    rtpStyle.RightMargin = RULER_ONE_INCH * 0.75
    Call RTField.AppendText("" & "Indented Paragraph by 1/2 inch.")
    Call RTField.AppendText("" & vbCrLf & vbCrLf)
    Call RTField.AppendText("" & "Ending paragraph back at original margin.")
    'Place in Draft
    Call memo.Save(True, True)
    Set S = Nothing
    Set db = Nothing
End Sub

Open in new window

donnamlambAuthor Commented:
Thanks for your help.

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now