- Katılım
- 8 Temmuz 2004
- Mesajlar
- 254
- Excel Vers. ve Dili
- office 2007-mssql 2008 R2
Bunu deneyin. Size aktif sayfayı HTML'e çevirecek kodları göndermemişim.Kendim denedim çalışıyor. Bu sefer problem olmaması lazım. Ayrıca bunları Sn.Alpen'in verdiği http://www.rondebruin.nl sitesinden almıştım. orayı bir ziyaret ederseniz farklı şeyler olduğunu göreceksiniz. Kolay gelsin.
Private Sub CommandButton2_Click()
Dim OutApp As Outlook.Application
Dim NewMail As Outlook.MailItem
Set OutApp = New Outlook.Application
Set NewMail = CreateItem(olMailItem)
With NewMail
.To = "falan@hotmail.com"
.Subject = .Subject = [a2]
.HTMLBody = SheetToHTML(ActiveSheet)
.Save
.Send
End With
Set NewMail = Nothing
Set OutApp = Nothing
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
Private Sub CommandButton2_Click()
Dim OutApp As Outlook.Application
Dim NewMail As Outlook.MailItem
Set OutApp = New Outlook.Application
Set NewMail = CreateItem(olMailItem)
With NewMail
.To = "falan@hotmail.com"
.Subject = .Subject = [a2]
.HTMLBody = SheetToHTML(ActiveSheet)
.Save
.Send
End With
Set NewMail = Nothing
Set OutApp = Nothing
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
