【问题标题】:Copy Excel chart to Outlook mail message将 Excel 图表复制到 Outlook 邮件
【发布时间】:2014-09-01 10:34:58
【问题描述】:

我在 A 列中有电子邮件地址,在同一张表中有一个图表对象。

对于每个电子邮件地址,我想在 Outlook 中创建一个新邮件并将 Excel 图表粘贴到电子邮件正文中。

我尝试的问题(如下)是图表没有粘贴到邮件正文中。我该如何解决?

这是我的代码:

Sub smail()        
    Dim r As Integer
    Dim o As Outlook.Application
    Dim m As Outlook.MailItem
    Set o = New Outlook.Application
    r = 1
    Do While Cells(r, 1) <> ""
        Set m = o.CreateItem(olMailItem)
        m.To = Cells(r, 1)
        m.CC = "xyz@anc.com"
        m.BCC = "abc@xyz.com"
        m.Subject = "Test"
        ActiveChart.ChartArea.Copy
        Set wEditor = o.ActiveInspector.WordEditor
        'm.Body = Paste
        wEditor.Application.Selection.Paste

        m.Send
        r = r + 1
        Set m = Nothing
    Loop
End Sub

【问题讨论】:

    标签: vba excel outlook


    【解决方案1】:

    我认为这条线的问题

    wEditor.Application.Selection.Paste
    

    是什么都不选择,即.Selection 返回Nothing,只要消息不可见。要解决此问题,请在粘贴前使其可见:

    m.Display
    

    这对我有用。

    此外,您应该始终使用Dim 声明所有变量,包括wEditor:

    Dim wEditor As Word.Document
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-12-20
      • 1970-01-01
      • 2022-07-16
      • 1970-01-01
      • 2022-08-13
      • 2022-01-27
      • 2017-07-05
      • 2020-04-01
      相关资源
      最近更新 更多