I am using excel and Outlook 2010, and I am trying to get the below code to paste a chart from excel to the body of an outlook email. The code does not show the chart. I was wondering what I need to change to have the chart show up??
Sub Email_Turnover() Dim rng As Range Dim OutApp As Object Dim OutMail As Object Dim Sht As String Sht = ActiveWorkbook.ActiveSheet.Range("F3").Value Dim ws As Worksheet Set ws = Sheets(Sht) Dim sbj As String Dim Line As String Line = ActiveWorkbook.ActiveSheet.Range("B3").Value Dim dte As Date dte = Date Dim CheckBox1 As Object Set CheckBox1 = Sheets(Sht).CheckBox1 If CheckBox1 = False Then MsgBox "You must verify that you are ready to email this communication. Please check the box." Exit Sub End If If Line = "FT 55" Then sbj = "FT 55 Daily Communication" ElseIf Line = "ML11" Then sbj = "ML11 communication" ElseIf Line = "Fully Lathed" Then sbj = "Fully Lathed Communication" End If Set rng = Nothing On Error Resume Next ws.Unprotect Set rng = ws.Range("A1:P55") On Error GoTo 0 With Application .EnableEvents = False .ScreenUpdating = False End With Set OutApp = CreateObject("Outlook.Application") Set OutMail = OutApp.CreateItem(0) On Error Resume Next With OutMail .To = "FT 55 Daily Communication" .CC = "" .BCC = "" .Subject = sbj & " " & dte & " " & Sht & " " & "Shift" .HTMLBody = RangetoHTML(rng) .Display End With On Error GoTo 0 With Application .EnableEvents = True .ScreenUpdating = True End With Set OutMail = Nothing Set OutApp = Nothing Sheets(Sht).CheckBox1 = False ws.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True, AllowInsertingHyperlinks:=True End Sub Function RangetoHTML(rng As Range) Dim fso As Object Dim ts As Object Dim TempFile As String Dim TempWB As Workbook TempFile = Environ$("temp") & "\" & Format(Now, "dd-mm-yy h-mm-ss") & ".htm" 'Copy the range and create a new workbook to paste the data in rng.Copy Set TempWB = Workbooks.Add(1) With TempWB.Sheets(1) .Cells(1).PasteSpecial Paste:=8 .Cells(1).PasteSpecial xlPasteValues, , False, False .Cells(1).PasteSpecial xlPasteFormats, , False, False .Cells(1).Select Application.CutCopyMode = False On Error Resume Next .DrawingObjects.Visible = True .DrawingObjects.Delete On Error GoTo 0 End With 'Publish the sheet to a htm file With TempWB.PublishObjects.Add( _ SourceType:=xlSourceRange, _ Filename:=TempFile, _ Sheet:=TempWB.Sheets(1).Name, _ Source:=TempWB.Sheets(1).UsedRange.Address, _ HtmlType:=xlHtmlStatic) .Publish (True) End With 'Read all data from the htm file into RangetoHTML Set fso = CreateObject("Scripting.FileSystemObject") Set ts = fso.GetFile(TempFile).OpenAsTextStream(1, -2) RangetoHTML = ts.readall ts.Close RangetoHTML = Replace(RangetoHTML, "align=center x:publishsource=", _ "align=left x:publishsource=") 'Close TempWB TempWB.Close savechanges:=False 'Delete the htm file we used in this function Kill TempFile Set ts = Nothing Set fso = Nothing Set TempWB = Nothing End Function