Attaching Chart to Email?

  • Thread starter Thread starter CWLee
  • Start date Start date
C

CWLee

I have an Excel spreadsheet, and derived from it 5 charts.
How can I attach one of the charts to an email to send to
someone?

(I know how to attach the whole spreadsheet, and the
associated charts, but I don't want to send the spreadsheet
and the other 4 charts, because they contain data not
appropriate to share with the email recipient.)

Thanks.

--
 
Hi


Change the path if it not exist

'fill in the file path/name of the gif file
Fname = "C:\My_Sales1.gif"

It will create a gif file in this location and after it send the mail it will delete this file



Change the sheet name to the sheet where the chart is and change the name of the chart in this code line

ActiveWorkbook.Worksheets("Sheet1").ChartObjects("Chart 1").Chart.Export _
Filename:=Fname, FilterName:="GIF"


Fill in your mail address to test the code
.To = "(e-mail address removed)"


Now Run the code



Sub SaveSend_Embedded_Chart()
'Working in 2000-2007
Dim OutApp As Object
Dim OutMail As Object
Dim Fname As String

Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)

'fill in the file path/name of the gif file
Fname = "C:\My_Sales1.gif"

'if you hold down the CTRL key when you select the chart
'in 2000-2003 you see the name in the name box(formula bar)
ActiveWorkbook.Worksheets("Sheet1").ChartObjects("Chart 1").Chart.Export _
Filename:=Fname, FilterName:="GIF"

On Error Resume Next
With OutMail
.To = "(e-mail address removed)"
.CC = ""
.BCC = ""
.Subject = "This is the Subject line"
.Body = "Hi there"
.Attachments.Add Fname
.Send 'or use .Display
End With
On Error GoTo 0

Kill Fname
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
 
Thanks again. Sorry to say, I am completely unable to
understand what you suggest as a way to email a chart from
an Excel spreadsheet. I'm sure your technological knowledge
is sound, but your manner of presentation is too advanced
for me. Thanks again.

====================
 
If it is your fist macro it is not so easy <g>

Send me your workbook private and tell me which chart you want to send and I will
add the code to the workbook for you
 
Back
Top