我已经尝试了几天,但没有找到任何解决方案。
我有一个带有数据透视表的excel工作表(此数据每周都会更改),并且希望仅在电子邮件正文中将其作为文本发送。我使用了rondebruin的代码,但是该代码与表一起显示数据。我正在使用以下代码。
Private Sub Workbook_Open()
Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
strbody = "<font face=""Calibri"" color=""Black"">" & _
Range("B7").Text & " (" & Range("B6").Value & " of " & Range("B2") & " complete) of all Scheduled Changes have completed so far. " & Range("B4").Value & " Changes have been cancelled or backed out." & "<br>" & "<br>" & _
Range("A17").Value & "<br>" & _
"</font>" & _
"<font face=""Calibri"" color=""Blue"">" & _
Range("A23").Value & " " & Range("B23").Value & "<br>" & _
"</font>"
On Error Resume Next
With OutMail
.To = ""
.CC = ""
.BCC = ""
.Subject = "Weekend Maintenance 10 am Status Update"
.HTMLBody = strbody
.Display
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
我希望的输出应该是“透视表”中的“仅文本”,该表每周更改一次。另外,当我使用范围时,出现类型不匹配错误。我已经按照其他论坛的建议使用了Rng,但是这给了我邮件正文中带有表格(无边框)的数据。
请帮助/建议...