1

I'm trying to paste several Excel ranges as images on Outlook body.

I have this code working, but when i paste the image it erase the .HTMLBody that I have already written inside the email body.

How do I keep the HTMLBody paste the image after.

Dim r As Range
Set r = Range("A1:U49")
r.Copy

'Open a new mail item
Dim outlookApp As Outlook.Application
Set outlookApp = CreateObject("Outlook.Application")
Dim outMail As Outlook.MailItem
Set outMail = outlookApp.CreateItem(olMailItem)
Dim wordDoc As Word.Document
Set wordDoc = outMail.GetInspector.WordEditor

'Get its Word editor

With outMail
    .display
    .HTMLBody = "<p>Boa tarde,</p>" & _
    "<p>Segue abaixo para acompanhamento <strong>gerencial</strong> dos ritmos de opera&ccedil;&otilde;es.</p>" & _
    "<p>Essa visibilidade di&aacute;ria &eacute; importante para medir como estamos em rela&ccedil;&atilde;o ao plano (IBP-S&amp;OP) e a capacidade informada.</p>" & _
    "<p><em>LEGENDA </em></p>"

End With

wordDoc.Range.PasteAndFormat wdChartPicture
Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
  • Possible duplicate of [Copying range including formatting when pasting in Outlook email body](https://stackoverflow.com/questions/49163778/copying-range-including-formatting-when-pasting-in-outlook-email-body) – L42 Mar 28 '18 at 01:36

1 Answers1

0

the issue is you're replace the htmlbody with wordDoc.Range.PasteAndFormat wdChartPicture

Looks like you have multiple paragraphs on your HTMLBody so work with Paragraphs Object (Word). The Paragraphs property return the Paragraphs collection Paragraphs(1) or (2) and so on then decide where to place the image.

Example

wordDoc.Paragraphs(1).Range.PasteAndFormat wdChartPicture

By using the paragraphs collection you will be working with current HTMLBody and keep your signature, etc ...

0m3r
  • 12,286
  • 15
  • 35
  • 71