Email Pivot Table Chart

Skybluekid

Well-known Member
Joined
Apr 17, 2012
Messages
1,226
Office Version
  1. 365
Platform
  1. Windows
Hi

I am using the below code to email a Pivot Chart in the body of an email. I am getting a runtime 438 error. Any help would be appreciated.

Sub ChartMail()


Dim TempFilePath As String
Dim TempFileName As String
Dim OutApp As Object
Dim OutMail As Object
Dim Salu As String
Dim BodyText As String
Dim EndText As String
Dim Fnmae As String


Application.ScreenUpdating = False
Application.EnableEvents = False




'Define Text Strings
Salu = Sheet11.Range("S6").Value


BodyText = ""

EndText = ""

Fname = Path & Sheet11.Range("B3").Value & " June2018" & ".jpg"

'Save Graph
ActiveWorkbook.Sheet11.ChartsObjects("Chart 1").Chart.Export filename:=Fname, FilterName:="jpg"




Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)

On Error Resume Next
With OutMail
.Importance = 2
.To = Sheet11.Range("S4").Value
.CC = ""
.BCC = ""
.Subject = "Penalty Charge Statistics - " & Sheet11.Range("B3").Value
.HTMLBody = BodyText & "<img src = Fname>" & EndText

'.Send
.Display
End With
On Error GoTo 0

End Sub
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
1. Remove On Error Resume Next
2. on which line do you get error 438?


On this Line ActiveWorkbook.Sheet11.ChartsObjects("Chart 1").Chart.Export filename:=Fname, FilterName:="jpg"
 
Upvote 0
Well, then debug that line. Use Debug.Print. What is the evaluated file name for instance? Simplify the line till you get no error.
 
Upvote 0

Forum statistics

Threads
1,215,530
Messages
6,125,350
Members
449,220
Latest member
Edwin_SVRZ

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top