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>
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>