I've got a VBA macro that creates a new email in outlook, copies some charts from excel, and pastes them in the new email. It works great, except the colors of the bar charts change after I paste.
If I manually copy and paste into the email and click "keep source formatting", the colors are correct. I can't get an equivalent option to work in vba.
I try to use xlPasteFormats or xlPasteAllUsingSourceTheme, but neither of those keep the correct colors.
I've also tried using CopyPicture instead of Copy, but the quality of the charts don't look right, they look more pixelated.
I've also tried every way I can find to change the default colors in outlook, but that hasn't helped either.
Here's the relevant code:
Sub CopyAndPasteToMailBody()
Set mailApp = CreateObject("Outlook.Application")
Set mail = mailApp.CreateItem(olMailItem)
mail.Display
Set wEditor = mailApp.ActiveInspector.wordEditor
For Each ws In Worksheets
If ws.Name = "results" Then
For Each cht In ws.ChartObjects
cht.Copy
With wEditor.Application.Selection
.Paste
.InsertAfter vbCrLf
.Collapse Direction:=wdCollapseEnd
End With
Next cht
End If