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.
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.


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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

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…
You’ve got a lotus Domino web server, and you have been told that “leverage browser caching” is a must do. This means that we have to tell the browser everywhere in the web to use cache. In other words, we set (and send) an expiration date in the HT…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

743 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

12 Experts available now in Live!

Get 1:1 Help Now