Sending a range as an image attached to an e-mail

R

robertp

Hello,

I've read many threads on here recently regarding sending e-mails
containing ranges of cells from excel which has been very helpful.

I'm sure I also read how to attach an image of a range (after using the
range.copypicture method) to an e-mail, but I can no longer find it.

I don't want to embed the image directly into a HTML or rich text
e-mail, just as a bmp or jpg attachment.

I wonder if anybody could please explain how to do this.

Thanks,

Rob Pearce
 
R

Ron de Bruin

Hi Rob

You can use code like this to create a gif file

Sub Testing()
Application.ScreenUpdating = False
Selection.CopyPicture Appearance:=xlScreen, Format:=xlPicture

Set ctoTheChartHolder = ActiveSheet.ChartObjects.Add(0, 0, 800, 600)

Set chtTheChart = ctoTheChartHolder.Chart

' Paste the picture onto the chart and
' set an object variable for it
ctoTheChartHolder.Activate
With chtTheChart
.ChartArea.Select
.Paste
Set picThePicture = .Pictures(1)
End With

' Set the picture's properties...
With picThePicture
.Left = 0
.Top = 0
sglWidth = .Width + 7
sglHeight = .Height + 7
End With

' Change the size of the chart object to fit the picture
'better
With ctoTheChartHolder
.Border.LineStyle = xlNone
.Width = sglWidth
.Height = sglHeight
End With
' Export the chart as a graphics file
blnRet = chtTheChart.Export(Filename:="c:\range.gif", _
FilterName:="gif", Interactive:=False)
ctoTheChartHolder.Delete
Application.ScreenUpdating = True
End Sub

Or use Harald's code
http://www.mvps.org/dmcritchie/excel/xl2gif.htm

Then you can use the Outlook code on my site to add the gif to the mail
http://www.rondebruin.nl/sendmail.htm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top