Email image of range

Mr_Adams

Active Member
Joined
Oct 7, 2002
Messages
475
Ivan Moala posted this code that puts an image of a range on a userform.

Instead of puting it on a userform I was hoping someone out there could tell me how to email the image as an attament
eamil (outlook) excel (multiple versions, 97 being the oldest, 2003 being the newest)

<font face=Courier New><SPAN style="color:#00007F">Private</SPAN> <SPAN style="color:#00007F">Sub</SPAN> UserForm_Initialize()
LoadImg
Frame1.Zoom = 100
TextBox1.Value = 100
SpinButton1.Value = 100
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN>
<SPAN style="color:#007F00">'**********************</SPAN>
<SPAN style="color:#007F00">'* Ivan F Moala *</SPAN>
<SPAN style="color:#007F00">'* http:www.xcelfiles.com *</SPAN>
<SPAN style="color:#007F00">'* 16th Jan 2003*</SPAN>
<SPAN style="color:#007F00">'**********************</SPAN>
<SPAN style="color:#00007F">Private</SPAN> <SPAN style="color:#00007F">Sub</SPAN> LoadImg()
<SPAN style="color:#00007F">Dim</SPAN> MyChart <SPAN style="color:#00007F">As</SPAN> Chart
<SPAN style="color:#00007F">Dim</SPAN> objPict <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Object</SPAN>
<SPAN style="color:#00007F">Dim</SPAN> RgCopy <SPAN style="color:#00007F">As</SPAN> Range
<SPAN style="color:#007F00">'On Error Resume Next</SPAN>
<SPAN style="color:#00007F">Set</SPAN> RgCopy = Sheets("Form").Range("B2:S52")
<SPAN style="color:#007F00">'On Error GoTo 0</SPAN>
RgCopy.CopyPicture Appearance:=xlScreen, Format:=xlBitmap
ActiveSheet.PasteSpecial Format:="Bitmap"
Selection.Name = "Img1"
<SPAN style="color:#00007F">Set</SPAN> objPict = ActiveSheet.Shapes("Img1")
<SPAN style="color:#00007F">With</SPAN> objPict
.CopyPicture 1, 1
<SPAN style="color:#00007F">Set</SPAN> MyChart = ActiveSheet.ChartObjects.Add(1, 1, .Width + 10, .Height + 10).Chart
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN>
<SPAN style="color:#00007F">With</SPAN> MyChart
.Paste
.Export "M:\Address Book\Temp.gif"
.Parent.Delete
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN>
<SPAN style="color:#007F00">'// Clean-up</SPAN>
objPict.Delete
<SPAN style="color:#00007F">Set</SPAN> MyChart = <SPAN style="color:#00007F">Nothing</SPAN>
<SPAN style="color:#00007F">Set</SPAN> RgCopy = <SPAN style="color:#00007F">Nothing</SPAN>
<SPAN style="color:#00007F">Set</SPAN> objPict = <SPAN style="color:#00007F">Nothing</SPAN>
<SPAN style="color:#00007F">With</SPAN> Frame1
.Picture = LoadPicture("M:\Address Book\Temp.gif")
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN>
Kill ("M:\Address Book\Temp.gif")
Xit:
Me.Repaint
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.

Forum statistics

Threads
1,214,598
Messages
6,120,441
Members
448,966
Latest member
DannyC96

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top