Consulting

Results 1 to 2 of 2

Thread: Urgent - aligning text to the right

  1. #1

    Urgent - aligning text to the right

    Hello
    i wrote a code which copy data from excel to outlook (no HTML).
    the text is written in right hand language and there for should be align to the right.
    the problem is that the email body is align to the left and i don't know how to change that.
    i have to present my work tomorrow- help is nedded !!!!!!
    i added the code and the text i want to align is in the "strbody" varaible (email body)

    thank you

    [VBA]Sub mail_person()
    Dim a As Integer, b As Integer
    Dim OutApp As Object
    Dim OutMail As Object
    Dim strbody As String, combine As String, item As String, item_name As String
    a = 1
    'concatenate all array value just for presentation
    If arr > 1 Then
    For concatenate = a To arr - 1
    x = x & "LRU Name : " & LRU1(a) & " " & "Quantity : " & LRU_quantity(a) & Chr(10)
    a = a + 1
    Next
    Else
    x = ""
    End If
    item = Worksheets("sheet1").Range("b2").Value
    item_name = Worksheets("sheet1").Range("b3").Value
    Set OutApp = CreateObject("Outlook.Application")
    OutApp.Session.Logon
    'create new messange - the each number define different outlook option
    Set OutMail = OutApp.CreateItem(0)
    'the outlook message
    strbody = "Hello" & vbNewLine & vbNewLine & _
    "This email was sent to update you on obsolite items " & _
    "in your project : " & pro_code & vbNewLine & _
    "Inventory : " & inventory & vbNewLine & _
    "price : " & price & vbNewLine & _
    "LRU Name : " & pro_inner_code & " " & "Quantity : " & sum_quantity & vbNewLine & _
    x & vbNewLine & vbNewLine & _
    "Best regards" & vbNewLine & vbNewLine & name
    On Error Resume Next
    With OutMail
    .To = ""
    .CC = ""
    .BCC = ""
    .Subject = "Program Obsolite Update -" & item
    .body = strbody
    .display
    End With
    With OutApp.body.Selection
    .paragraphformat.Alignment = center
    End With
    On Error GoTo 0

    End Sub[/VBA]

  2. #2
    VBAX Tutor nst1107's Avatar
    Joined
    Nov 2008
    Location
    Monticello
    Posts
    245
    Location
    I wish I could help, but Outlook isn't registered on my system, or I don't have the .dll, or something. Whatever it is, I'd need help to know how to fix it. However, just a pointer in case no one else notices it, you have mispelled "obsolete" in your strbody.

    You might try .paragraphformat.Alignment = msoAlignRight, instead of .paragraphformat.Alignment = center. I don't know if it will work, but maybe.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •