VBA电子邮件与贴图和文本在正文 [英] VBA Email with pasted chart and text in body

查看:837
本文介绍了VBA电子邮件与贴图和文本在正文的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下代码的目标是将所选图表粘贴到我的文本下方的电子邮件正文中。但是,它仍然将其粘贴到我的文本上方。如何更改它,使其粘贴到下面?谢谢!

The goal of the following code is to paste the selected chart into the email body below my text. However, it continues to paste it above my text. How can I change it to make it paste below? Thanks!

Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
With OutMail
    .CC = "xyz@anc.com"
    .BCC = "abc@xyz.com"
    .Subject = "Test"
    .Body = "Dear" & "Macro "

    ActiveSheet.Range("P36:X46").Copy
    Set wEditor = OutApp.ActiveInspector.WordEditor

    wEditor.Application.Selection.Paste

.display


推荐答案

更改选择开始和结束。添加额外的换行符也可能是一个好主意。您还应该使用MailItem.GetInspector而不是Application.ActiveInspector,因为消息尚未显示。

Change the selection start and end. Adding an extra line break might also be a good idea. You should also use MailItem.GetInspector instead of Application.ActiveInspector since the message is not yet displayed.

Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
With OutMail
    .CC = "xyz@anc.com"
    .BCC = "abc@xyz.com"
    .Subject = "Test"
    .Body = "Dear" & "Macro " & vbCrLf

    ActiveSheet.Range("P36:X46").Copy
    set vInspector = OutMail.GetInspector
    Set wEditor = vInspector.WordEditor

    wEditor.Application.Selection.Start = Len(.Body)
    wEditor.Application.Selection.End = wEditor.Application.Selection.Start

    wEditor.Application.Selection.Paste

.display

这篇关于VBA电子邮件与贴图和文本在正文的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆