【问题标题】:VBA Excel - Pasting a Chart in Outlook Mail Body (Not as image)VBA Excel - 在 Outlook 邮件正文中粘贴图表(不是图像)
【发布时间】:2018-08-21 23:36:12
【问题描述】:

我正在尝试使用 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

有人有不使用图片的解决方案吗?

【问题讨论】:

    标签: excel vba charts outlook


    【解决方案1】:

    您可以使用正在显示的消息的 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
    

    【讨论】:

    • 感谢您的回答。我在 .application 行中收到错误“运行时错误‘4605’此方法或属性不可用,因为文档已锁定无法编辑”。 .unprotect 也不起作用,它说它已经不受保护。知道如何解锁文档吗?
    • 查看here提供的答案是否有帮助。
    猜你喜欢
    • 2017-04-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-05
    • 2017-12-05
    • 1970-01-01
    相关资源
    最近更新 更多