我正在尝试创建一个宏,它从excel中取出一个表格,并将其粘贴到电子邮件中发送。我可以这样做,但表仍然是一个表,我想粘贴特殊的图像。我尝试了很多不同的方法和谷歌搜索,但都无济于事。请帮帮我。谢谢。
到目前为止的代码
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发布于 2012-11-06 01:31:55
下面是将所选表格复制为位图图片的代码,然后您可以使用标准的粘贴命令将表格粘贴为图片。
Selection.CopyPicture Appearance:=xlScreen, Format:=xlBitmaphttps://stackoverflow.com/questions/13236104
复制相似问题