【问题标题】:How to insert chart or graph into body of Outlook mail如何将图表或图形插入 Outlook 邮件正文
【发布时间】:2016-05-27 20:42:25
【问题描述】:

这里发布了一个关于如何使用 VBA 将图表插入到 Outlook 电子邮件正文的问题,我起草了一个答案,但后来消失了。

我认为没有 Sendkeys 会有更简单的方法,但看起来我错了!

无论如何,我想我会发布答案,以防原始海报仍在寻找,或者其他人需要它,或者即使有人可以提出更好的解决方案。

【问题讨论】:

标签: vba excel


【解决方案1】:
Sub charttoemail()

Dim myOutlook As Outlook.Application
Dim myMessage As Outlook.MailItem

On Error GoTo Handler
Set myOutlook = GetObject(, "Outlook.Application")
Set myMessage = myOutlook.CreateItem(olMailItem)

'Copy the chart
ActiveChart.ChartArea.Copy

    With myMessage

        .To = "steven@test.com"
        .Subject = "Here's your chart"
        .BodyFormat = olFormatHTML
        .Body = "Hi, Here's your chart" & vbCr & vbCr
        'Display to view the email and send to automatically fire it off
            .Display
            '.Send

    End With

'First key moves cursor to end of email and the second
'pastes the copied chart
SendKeys "^{END}"
SendKeys "^({v})", True

Set myOutlook = Nothing
Set myMessage = Nothing

Exit Sub

'If Outlook is not open, open it
Handler:

Set myOutlook = CreateObject("Outlook.Application")
Err.Clear
Resume Next

End Sub

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-07-20
    • 2017-12-05
    • 1970-01-01
    • 2014-01-09
    • 1970-01-01
    • 2015-11-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多