Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Copy and paste 2 excel sheets in message body of email

Hello all. I am using the following code in an excel workbook (it is
automated to email itself as an attachment) that copies and pastes
Sheet1 into the body of an email:

Public Function SheetToHTML(SH As Worksheet)
'Function from Dick Kusleika his site
'http://www.dicks-clicks.com/excel/sheettohtml.htm
'Changed by Ron de Bruin 04-Nov-2003
Dim TempFile As String
Dim Nwb As Workbook
Dim myshape As Shape
Dim fso As Object
Dim ts As Object
SH.Copy
Set Nwb = ActiveWorkbook
For Each myshape In Nwb.Sheets(1).Shapes
myshape.Delete
Next
TempFile = Environ$("temp") & "/" & _
Format(Now, "dd-mm-yy h-mm-ss") & ".htm"
Nwb.SaveAs TempFile, xlHtml
Nwb.Close False
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.GetFile(TempFile).OpenAsTextStream(1, -2)
SheetToHTML = ts.ReadAll
ts.Close
Set ts = Nothing
Set fso = Nothing
Set Nwb = Nothing
Kill TempFile
End Function

I am a rookie with VBA. How can I get this code to copy both Sheet1
and Sheet2 into the body of the email? Any ideas/suggestions will be
greatly appreciated. Have a nice day.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Copy and paste 2 excel sheets in message body of email

Hi rrmando

Use this

.HTMLBody = SheetToHTML(Sheet1) & SheetToHTML(Sheet2)

http://www.rondebruin.nl/mail/folder3/mail2.htm




--
Regards Ron de Bruin
http://www.rondebruin.nl


"rrmando" wrote in message oups.com...
Hello all. I am using the following code in an excel workbook (it is
automated to email itself as an attachment) that copies and pastes
Sheet1 into the body of an email:

Public Function SheetToHTML(SH As Worksheet)
'Function from Dick Kusleika his site
'http://www.dicks-clicks.com/excel/sheettohtml.htm
'Changed by Ron de Bruin 04-Nov-2003
Dim TempFile As String
Dim Nwb As Workbook
Dim myshape As Shape
Dim fso As Object
Dim ts As Object
SH.Copy
Set Nwb = ActiveWorkbook
For Each myshape In Nwb.Sheets(1).Shapes
myshape.Delete
Next
TempFile = Environ$("temp") & "/" & _
Format(Now, "dd-mm-yy h-mm-ss") & ".htm"
Nwb.SaveAs TempFile, xlHtml
Nwb.Close False
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.GetFile(TempFile).OpenAsTextStream(1, -2)
SheetToHTML = ts.ReadAll
ts.Close
Set ts = Nothing
Set fso = Nothing
Set Nwb = Nothing
Kill TempFile
End Function

I am a rookie with VBA. How can I get this code to copy both Sheet1
and Sheet2 into the body of the email? Any ideas/suggestions will be
greatly appreciated. Have a nice day.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Copy and paste 2 excel sheets in message body of email

Thanks for the reply Ron. I'm a big fan of yours by the way :) I
actually just realized that I was confused. I copied this function on
the sheet, but I am using your code that emails the workbook as an
attachment. I will try it out at the office on Monday.

Can I ask you more more semi-related question? We are using this excel
sheet for an automated purchase approval process. The email created
with this code gets replied to and moves up the ladder of approvers.
Is there any way to get this baby to ALWAYS copy the original sender so
that they know when their purchase has been approved, or so they know
where in the process their purchase requisition is? Thanks again.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Copy and paste 2 excel sheets in message body of email

Hello again. I have been trying to get

..HTMLBody = SheetToHTML(Sheet1) & SheetToHTML(Sheet2)

to work, but have been unsuccessful. I think I know why. The second
sheet is a Word document that I am inserting via:

Sub Add_Word_Document()
Application.ScreenUpdating = False
Dim MyFile
Sheets.Add After:=Worksheets(Worksheets.Count)
With ActiveWindow
.DisplayGridlines = False
.DisplayHeadings = False
.DisplayOutline = False
.DisplayZeros = False
End With
MyFile = Application.GetOpenFilename(FilterIndex:=5, Title:="Select
the file that you would like to add")
ActiveSheet.OLEObjects.Add(Filename:=(MyFile), Link:=False,
DisplayAsIcon:=False).Select
MyFile = Left(MyFile, Len(MyFile) - 4)
MyFile = Right(MyFile, Len(MyFile) - Len((Left(MyFile,
InStrRev(MyFile, "\")))))
ActiveSheet.Name = "Quote"
Range("A1").Select
Application.ScreenUpdating = True
End Sub

Any way to make the second sheet copy in the body of the email as well?
Thanks.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Copy and paste 2 excel sheets in message body of email

If you use 2002-2003 you can try the KB on top of my page

--
Regards Ron de Bruin
http://www.rondebruin.nl


"rrmando" wrote in message oups.com...
Hello again. I have been trying to get

.HTMLBody = SheetToHTML(Sheet1) & SheetToHTML(Sheet2)

to work, but have been unsuccessful. I think I know why. The second
sheet is a Word document that I am inserting via:

Sub Add_Word_Document()
Application.ScreenUpdating = False
Dim MyFile
Sheets.Add After:=Worksheets(Worksheets.Count)
With ActiveWindow
.DisplayGridlines = False
.DisplayHeadings = False
.DisplayOutline = False
.DisplayZeros = False
End With
MyFile = Application.GetOpenFilename(FilterIndex:=5, Title:="Select
the file that you would like to add")
ActiveSheet.OLEObjects.Add(Filename:=(MyFile), Link:=False,
DisplayAsIcon:=False).Select
MyFile = Left(MyFile, Len(MyFile) - 4)
MyFile = Right(MyFile, Len(MyFile) - Len((Left(MyFile,
InStrRev(MyFile, "\")))))
ActiveSheet.Name = "Quote"
Range("A1").Select
Application.ScreenUpdating = True
End Sub

Any way to make the second sheet copy in the body of the email as well?
Thanks.





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Copy and paste 2 excel sheets in message body of email

Sorry it is not possible to send objects/pictures with my code

--
Regards Ron de Bruin
http://www.rondebruin.nl


"rrmando" wrote in message oups.com...
Hello again. I have been trying to get

.HTMLBody = SheetToHTML(Sheet1) & SheetToHTML(Sheet2)

to work, but have been unsuccessful. I think I know why. The second
sheet is a Word document that I am inserting via:

Sub Add_Word_Document()
Application.ScreenUpdating = False
Dim MyFile
Sheets.Add After:=Worksheets(Worksheets.Count)
With ActiveWindow
.DisplayGridlines = False
.DisplayHeadings = False
.DisplayOutline = False
.DisplayZeros = False
End With
MyFile = Application.GetOpenFilename(FilterIndex:=5, Title:="Select
the file that you would like to add")
ActiveSheet.OLEObjects.Add(Filename:=(MyFile), Link:=False,
DisplayAsIcon:=False).Select
MyFile = Left(MyFile, Len(MyFile) - 4)
MyFile = Right(MyFile, Len(MyFile) - Len((Left(MyFile,
InStrRev(MyFile, "\")))))
ActiveSheet.Name = "Quote"
Range("A1").Select
Application.ScreenUpdating = True
End Sub

Any way to make the second sheet copy in the body of the email as well?
Thanks.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
email excel spreadsheet as body of message, not as attachment Email Spreadsheet as Body of Email Msg. Excel Discussion (Misc queries) 5 June 12th 06 03:23 PM
Body message - email al007 Excel Programming 2 January 24th 06 11:08 AM
Copy and Paste from Excel into Outlook Email message TroyB[_2_] Excel Programming 0 November 10th 04 08:01 AM
How to paste cells from Excel into Outlook email body? stastim Excel Programming 2 August 23rd 04 06:35 PM
Copy and Paste a Worksheet Range to Email Body Eric[_14_] Excel Programming 1 January 20th 04 12:06 AM


All times are GMT +1. The time now is 11:36 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"