将两个Excel范围作为图片粘贴到电子邮件中 [英] Pasting two Excel ranges into an email as pictures
本文介绍了将两个Excel范围作为图片粘贴到电子邮件中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用将Excel范围作为图片粘贴到电子邮件中的解决方案.如何将两个范围粘贴到电子邮件中?
I'm using a solution from Pasting an Excel range into an email as a picture. How can I paste two ranges into an email?
在下面的尝试中,第二张图片覆盖了第一张图片.我希望第二张图片出现在第一张图片之后.
In my attempt below, the second picture is overwriting the first picture. I would like the second picture to appear after the first one.
Private Sub generateEmail(rng As Range, rng2 As Range, strName As String)
'Open a new mail item
Dim outlookApp As Outlook.Application
Set outlookApp = CreateObject("Outlook.Application")
Dim outMail As Outlook.MailItem
Set outMail = outlookApp.CreateItem(olMailItem)
With outMail
.To = strName
.Subject = "** Please confirm Timesheet by 10:30AM **"
.Importance = olImportanceHigh
.Display
End With
'Get its Word editor
Dim wordDoc As Word.Document
Set wordDoc = outMail.GetInspector.WordEditor
'To paste as picture
rng.Copy
wordDoc.Range.PasteSpecial , , , , wdPasteBitmap
rng2.Copy
wordDoc.Range.PasteSpecial , , , , wdPasteBitmap
outMail.HTMLBody = "Timesheets Submitted by " & strName & "<br>" & _
Range("DateText") & vbNewLine & outMail.HTMLBody
End Sub
推荐答案
我能够通过将图片粘贴到两个单独的段落中来完成任务:
I was able to accomplish the task by pasting the pictures into two separate paragraphs:
'To paste as picture
rng.Copy
wordDoc.Paragraphs(1).Range.PasteSpecial , , , , wdPasteBitmap
wordDoc.Content.InsertParagraphAfter
rng2.Copy
wordDoc.Paragraphs(2).Range.PasteSpecial , , , , wdPasteBitmap
这篇关于将两个Excel范围作为图片粘贴到电子邮件中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文