I have been playing around with Ron de Bruin's code for the RangetoHTML function and I need to see if I can modify this solution to allow the additions of embedded charts and send in the body of a CDO email.
The other end of this is his macro that I have set to select Set rng = ActiveSheet.UsedRange. What I have is a sheet that has a handful of simple tables and then a couple of embedded charts that all need to go in the body of an email.
Any thoughts how to add some code so that these embedded charts get picked up as part of "rng" and are sent in the email body?
Function RangetoHTML(rng As Range)
' Changed by Ron de Bruin 28-Oct-2006
' Working in Office 2000-2007
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 past the data in
Set TempWB = Workbooks.Add(1)
.Cells(1).PasteSpecial xlPasteValues, , False, False
.Cells(1).PasteSpecial xlPasteFormats, , False, False
Application.CutCopyMode = False
On Error Resume Next
.DrawingObjects.Visible = True
On Error GoTo 0
'Publish the sheet to a htm file
With TempWB.PublishObjects.Add( _
'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
RangetoHTML = Replace(RangetoHTML, "align=center x:publishsource=", _
'Delete the htm file we used in this function
Set ts = Nothing
Set fso = Nothing
Set TempWB = Nothing