With the following VBA code I'm attempting to copy a chart from the active sheet to an email body, however I keep getting run-time error 91 - Object variable or With block variable not set, what is the cause of this?
Additionally once I get past this issue I'd like to copy numerous charts to the same email, would simply copying the code specific to capturing the chart on the active sheet with the next chart name be the most efficient?
Thanks
Sub testmailchart()
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
With OutMail
.To = "xxx.com"
.Subject = "Test"
'.Body = "See charts below" & vbCrLf
Set vInspector = OutMail.GetInspector
Set wEditor = vInspector.WordEditor
ActiveSheet.ChartObjects("Test Chart").Activate
ActiveChart.ChartArea.Copy
wEditor.Application.Selection.Start = Len(.Body)
wEditor.Application.Selection.End = wEditor.Application.Selection.Start
wEditor.Application.Selection.Paste
.Display
End With
End Sub
Bookmarks