1

I have an VBA code which allows me to populate an Outlook Template.

Nevertheless it does not keep the Excel formatting

e.g. "1 500 000,00€" become "1500000" in the email as the format is not kept when generating the email. Same with percentage when "85%" becomes "0.85" in the email.

Is there a way to keep the Excel format when populating the outlook template?

    Sub mailEN()
Dim myOlApp As Outlook.Application
Dim MyItem As Outlook.MailItem
Dim template As String

template = "C:\Users\LEVY\Desktop\testfinal.oft"

Set myOlApp = CreateObject("Outlook.Application")
Set MyItem = myOlApp.CreateItemFromTemplate(template)

With MyItem
    .To = xx
    .Subject = xx
    .HTMLBody = Replace(.HTMLBody, "#NOMINAL#", Worksheets("Feuil1").Range("C29"))
    .Display
End With
Set MyItem = Nothing
Set myOlApp = Nothing
End Sub

The problem is at .HTMLBody = Replace(.HTMLBody, "#NOMINAL#", Worksheets("Feuil1").Range("C29")) where the replacement does not keep the format.

BenjamLev
  • 27
  • 4

0 Answers0