gpt4 book ai didi

VBA 电子邮件,正文中粘贴有图表和文本

转载 作者:行者123 更新时间:2023-12-02 04:32:55 27 4
gpt4 key购买 nike

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

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,因为消息尚未显示。

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 电子邮件,正文中粘贴有图表和文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30944202/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com