excel - VBA Excel - 在 Outlook 邮件正文中粘贴图表(不是图像)
问题描述
我正在尝试使用 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
有人有不使用图像的解决方案吗?
解决方案
您可以使用正在显示的消息的 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
推荐阅读
- c# - 如何在 Visual Studio 2019 中禁用关于 System.String 的浮动提示
- python - 模块已安装但导入 cartopy 时出错
- css - 我如何使用 flexbox 来实现它?
- selenium - 文件未在 Selenium 上使用 WebElement 上传
- latitude-longitude - MathNet 距离计算的单位是什么?
- spring - 是否可以使用 Spring-boot 在通用库中实现 Swagger?
- hyperledger-fabric - HL Fabric - 状态、事务但不同的键
- scala - Spark Scala 余弦相似度矩阵
- corda - 即使类星体文件在目录中,FlowTests 也会出错
- ios - tvOS - 嵌套的 CollectionView 没有正确聚焦