【发布时间】:2017-10-25 03:12:38
【问题描述】:
给出下面的函数,我想将变量 %TABLE_HERE% 替换为从 Excel 电子表格范围生成的表格,该表格也附加到电子邮件中。
Public Function GenerateEmail(fileName As String, tbleRange As Range)
Application.ScreenUpdating = False
Dim OutApp As Object
Dim OutMail As Object
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItemFromTemplate(fileName)
With OutMail
.HTMLbody = Replace(OutMail.HTMLbody, "%TABLE_HERE%", RangetoHTML(tbleRange))
.Attachments.Add (Application.ActiveWorkbook.FullName)
.Display
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
End Function
我做了一些研究,发现了一个很棒的功能,它可以为您完成所有这些工作,并想在这里与大家分享!请参考下面我的回答
【问题讨论】:
-
您是否让它以您想要的方式与图表一起使用?
-
我做到了,效果也很好!