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

查看:106
本文介绍了将格式化的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

推荐答案

放入.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天全站免登陆