这是我用来复制范围以及打开新的 Excel 电子邮件的代码。 我可以很好地复制和粘贴,但我的问题是,当第二张图片粘贴时,它会替换第一张图片,而不是像我需要的那样粘贴在它上面。我做错了什么?
Private Sub CommandButton4_Click()
'Finds last Row of email report
Dim lRow As Long
Dim lCol As Long
lRow = Cells.Find(What:="*", _
After:=Range("A1"), _
LookAt:=xlPart, _
LookIn:=xlFormulas, _
SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious, _
MatchCase:=False).row
'Copy range of interest
Dim r As Range
Set r = Sheets("Email").Range(Cells(8, "E"), Cells(lRow, "N"))
r.Copy
'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 = ""
.CC = ""
.BCC = ""
.Subject = shift_txtb2.Text & " " & "Finishing Report" & " " & Format(Now(), "MM/DD/YY")
.HTMLBody = ""
'Attachments.Add
.Display
End With
''Get its Word editor
outMail.Display
Dim wordDoc As Word.Document
Set wordDoc = outMail.GetInspector.WordEditor
''To paste as picture
wordDoc.Range.PasteAndFormat wdChartPicture
Set r = Sheets("Email").Range("P8:T17")
r.Copy
wordDoc.Range.PasteAndFormat wdChartPicture
Unload Me
Sheets(1).Activate
End Sub
将其放在粘贴第二个之前:
wordDoc.Content.InsertParagraphAfter
您也可以尝试:
wordDoc.Content.TypeParagraph