Paste Excel Range to Outlook Email Body Using Chart Object
Paste Excel Range to Outlook Email Body Using Chart Object
Option Explicit
Sub PasteExcelRangeIntoChart()
Dim ch As Chart
Dim rng As Range
For Each ch In ThisWorkbook.Charts
ch.Delete
Next ch
Set ch = Charts.Add
Set ch = ch.Location(xlLocationAsObject, "Sheet1")
ch.Parent.Name = "ABC"
With Sheet1.Range("F3")
ch.Parent.Left = .Left
ch.Parent.Top = .Top
End With
With Sheet1.Range("B3:C9")
ch.Parent.Width = .Width
ch.Parent.Height = .Height
End With
Set rng = Sheet1.Range("B3:C9")
rng.CopyPicture xlScreen, xlBitmap
ch.Paste
ch.Export ThisWorkbook.Path & "\ABC.png"
Call SendEmail
End Sub
Sub SendEmail()
Dim oApp As Object
Dim oMail As Object
Dim imgPath As String
Set oApp = CreateObject("Outlook.Application")
Set oMail = oApp.createitem(0)
imgPath = ThisWorkbook.Path & "\ABC.png"
With oMail
.display
.htmlbody = "<img src=""" & imgPath & """>" & .htmlbody
End With
End Sub
Comments
Post a Comment