我正在尝试使用Union(从同一工作表)复制一定范围的单元格,然后将其粘贴到Outlook中的电子邮件中。
我现在有以下代码。问题是当我尝试将另一个范围添加到MultiR公式中时(设置r3 = Worksheets(“ EAMS Email”)。Range(“ P3:X19”)。我收到运行时错误1004,但似乎无法解决此问题。
'Copy range of interest for email
Dim MultiR As Range, r1 As Range, r2 As Range, r3 As Range
Set r1 = Worksheets("output").Range("B3:L12")
Set r2 = Worksheets("output").Range("B14:L19")
Set MultiR = Union(r1, r2)
'Copy range for email
MultiR.copy
'Open new email
Dim OutApp As Object
Dim OutMail As Object
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
'Get the Word editor
OutMail.Display
Dim worddoc As Object
Set worddoc = OutMail.GetInspector.WordEditor
'Paste as picture/bitmap
worddoc.Range.PasteSpecial DataType:=4
感谢您的帮助。