Posted to microsoft.public.excel.programming
|
|
Basic Excel macro problem with outlook
Hi Mike
http://www.rondebruin.nl/sendmail.htm#body
--
Regards Ron de Bruin
http://www.rondebruin.nl
"mike0021 " wrote in message ...
hey Ron,
Your page is great!!!!
I found a great script to use, but it is set up for all of the
worksheets in the workbook, and I just want it to use one worksheet.
How can I edit?
I commented out the lines that called for all of the worksheets... but
I cannot tell it just to use "calcs". Any suggestions?
Thanks so much!!!
Sub Outlook_Mail_every_Worksheet2()
Dim olApp As Outlook.Application
Dim olMail As MailItem
Dim ws As Worksheet
Application.ScreenUpdating = False
Set olApp = New Outlook.Application
'Sheets("Calcs").Select
ws = ThisWorkbook.Worksheets("Calcs")
'For Each ws In ThisWorkbook.Worksheets
'If ws.Range("a1").Value Like "*@*" Then
Set olMail = olApp.CreateItem(olMailItem)
With olMail
To = "
CC = ""
BCC = ""
Subject = "" & ws.Name
HTMLBody = SheetToHTML(ws)
Send
End With
Set olMail = Nothing
' End If
'Next ws
Set olApp = Nothing
Application.ScreenUpdating = True
End Sub
Public Function SheetToHTML(sh As Worksheet)
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
---
Message posted from http://www.ExcelForum.com/
|