我有一个带有图表的工作表,我想通过电子邮件正文发送它们。我的代码有效,但我想调整图表大小,因为它们太大了。第3个图表显示正确,但我没有看到第1和第2个图表。他们只是空白。
Sub Send_charts()
Dim OutApp As Object
Dim OutMail As Object
Dim ChartName1, ChartName2, ChartName3, Filename As String
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
ChartName1 = Environ$("temp") & "\Chart1.gif"
ActiveWorkbook.Worksheets("Sheet1").ChartObjects("Chart 1").Chart.Export _
Filename:=ChartName1, FilterName:="GIF"
ChartName2 = Environ$("temp") & "\Chart2.gif"
ActiveWorkbook.Worksheets("Sheet1").ChartObjects("Chart 2").Chart.Export _
Filename:=ChartName2, FilterName:="GIF"
ChartName3 = Environ$("temp") & "\Chart3.gif"
ActiveWorkbook.Worksheets("Sheet1").ChartObjects("Chart 3").Chart.Export _
Filename:=ChartName3, FilterName:="GIF"
On Error Resume Next
With OutMail
.Subject = "XX"
.HtmlBody = .HtmlBody & "<html><body><img src=" & "'" & ChartName1 & " height='200' width='450'><Br><Br><Br/></body></html>"
.HtmlBody = .HtmlBody & "<html><body><img src=" & "'" & ChartName2 & " height='150' width='250'><Br><Br><Br/></body></html>"
.HtmlBody = .HtmlBody & "<html><body><img src=" & "'" & ChartName3 & "'><Br><Br><Br/></body></html>"
.Display
End With
On Error GoTo 0
Kill ChartName1
Kill ChartName2
Kill ChartName3
Set OutMail = Nothing
Set OutApp = Nothing
End Sub