将格式化的 Excel 范围粘贴到 Outlook 邮件中 [英] Pasting formatted Excel range into Outlook message

查看:38
本文介绍了将格式化的 Excel 范围粘贴到 Outlook 邮件中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将一系列格式化的 Excel 单元格粘贴到 Outlook 邮件中.

I would like to paste a range of formatted Excel cells into an Outlook message.

以下代码(我从各种来源提取)运行时没有错误并发送一条空消息.

The following code (that I lifted from various sources), runs without error and sends an empty message.

Sub SendMessage(SubjectText As String, Importance As OlImportance)
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment
Dim iAddr As Integer, Col As Integer, SendLink As Boolean
'Dim Doc As Word.Document, wdRn As Word.Range
Dim Doc As Object, wdRn As Object

' Create the Outlook session.
Set objOutlook = CreateObject("Outlook.Application")
' Create the message.
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)

Set Doc = objOutlookMsg.GetInspector.WordEditor
'Set Doc = objOutlookMsg.ActiveInspector.WordEditor
Set wdRn = Doc.Range
wdRn.Paste

Set objOutlookRecip = objOutlookMsg.Recipients.Add("MyAddress@MyDomain.com")
objOutlookRecip.Type = 1
objOutlookMsg.Subject = SubjectText
objOutlookMsg.Importance = Importance

With objOutlookMsg
    For Each objOutlookRecip In .Recipients
        objOutlookRecip.Resolve
        ' Set the Subject, Body, and Importance of the message.
        '.Subject = "Coverage Requests"
        'objDrafts.GetFromClipboard
    Next
    .Send
End With
Set objOutlookMsg = Nothing
Set objOutlook = Nothing
End Sub

推荐答案

Put .Display before .Send,

Put .Display before .Send,

简单但快速的修复,您的问题是电子邮件在发送之前没有用粘贴的内容刷新,迫使它首先显示给它时间...

Simple but Quick fix, your problem is the email is not refreshing with the pasted contents before it sends, forcing it to Display first gives it time...

还要确保您有另一个宏在此之前运行以将范围复制到剪贴板中...

Also make sure you have another macro which runs before this to Copy the Range into your clipboard...

这篇关于将格式化的 Excel 范围粘贴到 Outlook 邮件中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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