从Excel 2016复制粘贴范围到Outlook 2016作为图片

时间:2017-10-11 13:44:53

标签: excel vba excel-vba email outlook

我正在尝试使用VBA将Excel范围粘贴到Outlook电子邮件的正文中作为图片。但是,每当我这样做时,粘贴操作中的范围会被切断。原始范围如下:

Original Range

粘贴显示如下:

Pasted Image

我基本上使用Jean-François Corbett中显示的Pasting an Excel range into an email as a picture的VBA代码。即:

Dim objOutlook As Object
Dim objMail As Object

Set objOutlook = CreateObject(Class:="Outlook.Application")
Set objMail = objOutlook.CreateItem(0)

'Copy range of interest
Dim r As Range
Set r = Range("B2:E14")
r.Copy

'Paste as picture in sheet and cut immediately
Dim p As Picture
Set p = ActiveSheet.Pictures.Paste
p.Cut

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

'Paste picture
wordDoc.Range.Paste

我知道还有其他代码示例将HTML粘贴(例如by Ron de Bruin),但最终会粘贴为我的表(而不是图片)。我还看过人们粘贴到图表中的例子,将图表保存为JPG,然后将JPG插入到电子邮件的HTMLBody中(例如by Mike Marshall),但这对我来说也是切断的

欣赏人们可以分享的任何见解!

0 个答案:

没有答案