Indent Paragraph Code for LotusScript

Posted on 2009-04-14
Last Modified: 2013-12-18
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.
Question by:donnamlamb
  • 5
  • 4
LVL 22

Expert Comment

ID: 24145921
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


Author Comment

ID: 24146930
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.


LVL 22

Expert Comment

ID: 24147898
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.
LVL 22

Accepted Solution

mbonaci earned 125 total points
ID: 24147931
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.
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.


Author Comment

ID: 24149560
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.
LVL 22

Expert Comment

ID: 24156980
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)...

Author Comment

ID: 24198708
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.


Author Comment

ID: 24209024
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 = ""



    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


Author Closing Comment

ID: 31570122
Thanks for your help.

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

For Desktop Techs: How to retain a user's Notes configuration data when swapping out the end user's computer. (Assuming that you are not upgrading to a completely different version of Notes client) All you need to do is: 1) install Notes o…
Notes Document Link used by IBM Notes is a link file which aids in the sharing of links to documents in email and webpages. The posts describe the importance and steps to create a Lotus Notes NDL file in brief.
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

896 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now