I'm struggling to find the correct syntax to export a chart from a chart sheet, not embedded in a worksheet. I used to have the chart embedded, but transferred it to it's own sheet at the request of the user and I can't seem to find anything to suit. Here is the code as it stood with an embedded chart, could someone give me a hint as to the syntax?
Public Sub ExportChart()
Dim varChartObject As ChartObject
Dim varChart As Chart
Dim varFilename As String
Dim varPath As String
Set varChartObject = Sheets("Output Chart").ChartObjects(1)
Set varChart = varChartObject.Chart
varFilename = Format(ThisWorkbook.Sheets("Parameters").Range("C5").Value, "YYYYMMDD")
varPath = "MyPath\" & Format(ThisWorkbook.Sheets("Parameters").Range("C5").Value, "MM. MMMM")
On Error Resume Next
Kill varPath & "\" & varFilename
On Error GoTo 0
varChart.Export Filename:=varPath & "\" & varFilename & ".png", Filtername:="PNG"
Set varChartObject = Nothing
Set varChart = Nothing
End Sub
Thanks in advance
You only need this at the start: