我正在尝试使用Excel VBA通过Outlook将图表粘贴到新电子邮件中。由于它失去太多分辨率,因此无法作为图像发送。 我需要完成的方式就像我手动进行的一样,只是复制和粘贴(Ctrl + C,Ctrl + V):
我的代码如下:
ThisWorkbook.Worksheets("Somatório_bacias").ChartObjects(1).Copy
'Envia o e-mail
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
With OutMail
.To = "myemail@gmail.com"
.Cc = ""
.Subject = ""
'Chart part goes around here
.send '.send or use .Display
End With
有人有不使用图像的解决方案吗?
答案 0 :(得分:2)
您可以使用所显示消息的Word文档对象模型。
With OutMail
'Display message to allow access to the Word Document Object Model
.Display
.To = "myemail@gmail.com"
.Cc = ""
.Subject = ""
'Access the Word Document Object Module
With .GetInspector.WordEditor
'Go to the end of the email (optional)
.Application.Selection.EndKey Unit:=6 'wdStory
'Add a new line (optional)
.Application.Selection.TypeParagraph
'Add a new line (optional)
.Application.Selection.TypeParagraph
'Paste the chart into the body of the email
.Application.Selection.Paste
End With
.send
End With