0

I've assembled the following code that creates the following text in the body of an Outlook email when run.

Sub InitialEvaluationWalkThru()
    Dim OutApp As Object
    Dim OutMail As Object
    Dim strto As String, strcc As String, strbcc As String
    Dim strsub As String, strbody As String

    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)

    strto = "first.last@me.com"
    strcc = ""
    strbcc = ""
    strsub = [$C$8] & " Update"
    strbody = "<H5>Hello Everyone,</H5>" & _
              "<H5>The Template conference rooms " & Cells(FormulaCell.Row, "C").Value & " phase is now complete!</H5>" & _
              "<H4>The overall room deployment is " & [$E$8] & "% Complete!</H4>" & _
              "<H5>Let me know if you have any questions,</H5>"

    With OutMail
        .Display
        .To = strto
        .CC = strcc
        .BCC = strbcc
        .Subject = strsub
        ' .Body = strbody
        .HTMLBody = strbody & .HTMLBody
        'You can add a file to the mail like this
        '.Attachments.Add ("C:\test.txt")
        .Send 'or use .Send
    End With

    Set OutMail = Nothing
    Set OutApp = Nothing
End Sub

Outlook Email

Hello Everyone,

The Template conference rooms Initial Evaluation Walk-Thru phase is now complete!

The overall room deployment is 0.125% Complete!

Let me know if you have any questions,

Question

I am trying to indent the third line and have tried many different combos with no luck. I've also tried to have the cell value percentage from my sheet as 13% not 0.125%, also with no luck.

Any help would be greatly appreciated.

Thank You

Brian M Stafford
  • 8,483
  • 2
  • 16
  • 25
DVDon
  • 21
  • 1
  • 3

1 Answers1

0

For the value, you should be able to simply multiply it by 100:

"<H4>The overall room deployment is " & CInt(100 * [$E$8]) & "% Complete!</H4>" &

CInt will round the value up or down. In your case it should round up 12.5 to 13.

As far as the tab, I would try what @JNevill suggests and use &#9; or &emsp; (see Special Characters) but put it in between <pre></pre> tags. See the many approaches discussed in this question: How to get a tab character?.

Étienne Laneville
  • 4,697
  • 5
  • 13
  • 29
  • Calculation worked - Thank You!!! I tried the
     tag but received Compile Error, Syntax Error. Am I not using it correctly?
    
    
    	
    "

    The overall room deployment is " & CInt(100 * [$E$8]) & "% Complete!

    " & _
    – DVDon Nov 15 '19 at 19:37
  • Put the
     tags inside the double quotes (after the H4 tag)
    – Étienne Laneville Nov 15 '19 at 19:42
  • That did the trick, but it changes my H4 heading font for some reason. "

    The overall room deployment is " & CInt(100 * [$E$8]) & "% Complete!

    "
    – DVDon Nov 15 '19 at 20:01
  • You can post that issue as a separate question and tag it as html-related. You can mark this question as answered by using the check mark to the left of the answer. – Étienne Laneville Nov 15 '19 at 22:38