0
votes

I tried this Microsoft Word Macro to paste the Selection I've done into a new email, but when I do it in HTML format, while there is not <br> at the end of each paragraph, the result is the sentence word by word without carriage return.

Example:
Text1
Text2
Text3

I get:
Text1 Text2 Text3

Dim rng As Range
Dim OutApp As Object
Dim OutMail As Object

Set rng = ActiveDocument.Range(Start:=Selection.Start, End:=Selection.End)

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

On Error Resume Next
With OutMail
    .Display
    .To = "[email protected]"
    .CC = "[email protected]"
    .BCC = ""
    .Subject = Date
    .BodyFormat = olFormatHTML
    .HTMLBody = "<HTML><body><font face=""calibri"" style=""font-size:11pt;""><br>" & rng & _
"<br><br></body>" & _
"Best Reagrds" & _
         .HTMLBody & "</font>"
    .Text
1
One way to solve this might to use a textbox. See stackoverflow.com/questions/45362791/…Tony M
In Word this doesn't work ! It came Compile error: Sub or Function not defined on Set r = Range ("B1)massimob1972
Right -- that code was made for Excel modules.Tony M

1 Answers

0
votes

try this in your code (untested)

dim sen as variant


.HTMLBody = "<HTML><body><font face=""calibri"" style=""font-size:11pt;""><br>"

for each sen in rng.sentences
    .htmlbody = .htmlbody & sen & "<br>"     ' may have to be sen.text
next sen

....