I need to copy contents from two sheets into Outlook mail body.
- Sheet 1 contains only text with some merged cells.
- Sheet2 contains charts.
My failed approach:
Copy contents from sheet1 and sheet2 into a temp sheet and then copy the complete content from temp sheet to mail body.
This approach messes the complete alignment once the content is pasted into Outlook mail body, even though it looks good in the temp sheet.
Below is the code snippet I use.
Sub copy_graph()
Dim outlookapp, outmail, worddoc As Object
Set outlookapp = CreateObject("outlook.application")
Set outmail = outlookapp.createitem(olmailitem)
outmail.display
Set worddoc = outmail.getinspector.wordeditor
ThisWorkbook.Sheets.Add.Name = "temp_mail"
ThisWorkbook.Worksheets("Tu_Mail").Range("a4:b18").Copy
ThisWorkbook.Worksheets("temp_mail").Range("a1").Select
ActiveSheet.Paste
ThisWorkbook.Worksheets("trend").Range("a1:x93").Copy
ThisWorkbook.Worksheets("temp_mail").Range("a19").Select
ActiveSheet.Paste
ThisWorkbook.Worksheets("temp_mail").Range("a1:x93").Copy
worddoc.Range.PasteExcelTable linkedtoexcel:=False, wordformatting:=False, RTF:=False
Application.DisplayAlerts = False
ThisWorkbook.Worksheets("temp_mail").Delete
End Sub
Is there any way to paste content from two sheets one by one into the mail body instead of combining them into one sheet. i.e paste as two different tables so that the column alignment is intact.
Or
Is there any other better approach for this?
RangeToHTML
is a common funtion i see in most of the answers in web. But it fails in my case, it doesnt copy charts. – Vivek