0

I am using vba in outlook to generate an email. I would like to find a way to move some text over to the right, about 100 pixels.

since I don't believe there is a way to incorporate css or styles in vba I am looking for a way to add more than one space to get the text moved over. however when I try space() function and " ", even if I repeat these codes a number of times it only ever gives me one space.

can someone please help me and show me what I need to do, thanks

"<br><br><br>" & "3PL & HAULAGE SUPPLIERS: " & " " & "<font size=""4.5"" face=""calibri"" color=""red"">" & "<b>" & EmailCount & "</b></font>" & vbNewLine & _
Jack Knight
  • 51
  • 1
  • 2
  • 6

1 Answers1

1

This will add 10 white spaces just before 3PL. You may need to adjust as the pixel distance will be relative to the font

TRIED AND TESTED

Sub test()

    Dim WS As String

    WS = "&nbsp"

    For i = 1 To 10
        WS = WS & "&nbsp"
    Next i

    Debug.Print "<br><br><br>" & WS & "3PL & HAULAGE SUPPLIERS: " & " " & "<font size=""4.5"" face=""calibri"" color=""red"">" & "<b>" & EmailCount & "</b></font>" & vbNewLine

End Sub
Mark Price
  • 78
  • 1
  • 6
  • You can avoid the `for` loop by using the string function `WS = string(10,"&nbsp")` Failing that try replacing the `"&nbsp"` with something like `chr(9)` – MMerry Oct 15 '14 at 08:55
  • 2
    @MMerry the above does not work as the string constructor has a syntax of String(Number as Long,Character) this will produce a string consisting of ten ampersands. Replacing the "&nbsp" with Chr(9) also does not work as when the html engine renders the code the leading white spaces will be removed. – Mark Price Oct 16 '14 at 02:07
  • of course, I forgot that string takes a _character_ not a _string_. – MMerry Oct 16 '14 at 06:02