0
我想創建一個宏,它從excel中獲取一張表並將其粘貼到電子郵件中併發送。我可以做到這一點,但桌子仍然是一張桌子,我想粘貼特殊圖像。我嘗試了很多不同的方法和大量的谷歌搜索,但無濟於事。請幫助...謝謝。Excel VBA到電子郵件
到目前爲止的代碼
TempFile = Environ$("temp") & "/" & Format(Now, "dd-mm-yy h-mm-ss") & ".htm"
'Copy the range and create a new workbook to past the data in
rng.Copy
Set TempWB = Workbooks.Add(1)
With TempWB.Sheets(1)
.Cells(1).PasteSpecial Format:="Picture (Enhanced Metafile)" 'Paste:=2
.Cells(1).PasteSpecial xlPasteValues, , False, False
.Cells(1).PasteSpecial xlPasteFormats, , False, False
.Cells(1).Select
Application.CutCopyMode = False
On Error Resume Next
.DrawingObjects.Visible = True
.DrawingObjects.Delete
On Error GoTo 0
End With
'Publish the sheet to a htm file
With TempWB.PublishObjects.Add(_
SourceType:=xlSourceRange, _
Filename:=TempFile, _
Sheet:=TempWB.Sheets(1).Name, _
Source:=TempWB.Sheets(1).UsedRange.Address, _
HtmlType:=xlHtmlStatic)
.Publish (True)
End With
'Read all data from the htm file into RangetoHTML
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.GetFile(TempFile).OpenAsTextStream(1, -2)
RangetoHTML = ts.ReadAll
ts.Close
RangetoHTML = Replace(RangetoHTML, "align=center x:publishsource=", _
"align=left x:publishsource=")
'Close TempWB
TempWB.Close savechanges:=False
您能簡單介紹一下你已經嘗試的途徑,以便試圖幫助或可能發現在你的做法是錯誤的時候別人不犯同樣的錯誤 – Ren
見http://www.htmlgoodies.com/beyond /css/article.php/3679231/How-to-Create-Great-HTML-Emails-with-CSS.htm。圖像必須採用特定的格式。 – Chloe