0

I send an inline table from Excel through Outlook.

I now want/need to add images to the table.

The problem is the formatting is lost between Excel and Outlook.

Is there a way to paste the range that contains images as a table while keeping the formatting?

The closest and cleanest way I can get to this is with this snippet:

Private Sub SENDBETABTTN_Click()
'Copy range of interest
Dim r As Range
Set r = MainDRK.Range("j3:aj" & MainDRK.Range("ae87").Value)
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)

'Get its Word editor
outMail.Display
Dim wordDoc As Word.Document
Set wordDoc = outMail.GetInspector.WordEditor

'To paste as picture
wordDoc.Range.PasteAndFormat wdFormatOriginalFormatting
End Sub

The remaining issue is I lose the placement of the images and in turn screw up the cell sizing of the table.

The end result looks like this: Bad Table
enter image description here

I am aiming for this: Good Table
enter image description here

braX
  • 11,506
  • 5
  • 20
  • 33
Craig Key
  • 1
  • 3
  • can you share the excel file? – 0m3r Oct 05 '19 at 06:10
  • I don't feel comfortable sharing the file due to company policy. It's a seemingly simple problem, I want to copy-paste a range from Excel into Outlook leaving me with a formatted table in Outlook. The problem is PNGs/JPEGs and "Shapes" cause spacing issues in the Outlook/pasted chart. – Craig Key Oct 07 '19 at 13:49

1 Answers1

0

Paste it as Type:=wdChartPicture MSDN

Also if needed, setup inlineshapes hight & width

    With wdDoc
        .InlineShapes(1).Height = 130
     End With

https://stackoverflow.com/a/48897439/4539709

0m3r
  • 12,286
  • 15
  • 35
  • 71
  • I have reverted to using wdChartPicture, this works fine as the spacing is persistent between applications, but is not the desired end as it pastes an image of the range rather than a table. I am having issues getting InlineShapes to function, but I will work on that a little more over today. I don't know if there are changes between 2013 and 2016 with InlineShapes, but I am currently using 2016. – Craig Key Oct 07 '19 at 14:21
  • @CraigKey look at this link the way I’m copying - https://stackoverflow.com/a/48897439/4539709 – 0m3r Oct 08 '19 at 10:00