I'm trying to export a range of cells in excel as an image using the code below. The export is working fine however the image is displaying a column chart underneath the image which seems to be created when I add the chart. Even If I don't select a range to copy and just add the chart it defaults to a column chart using some of the data on the sheet (very frustrating) The image I copied doesn't cover the whole chart screen so part of the column chart below is being displayed in the output.
I tried recording a macro by adding the chart manually then deleting the column chart that is appearing. I noticed a ActiveChart.Parent.Delete code is being used. When I attempt to use this code in my VBA below It throws an error
Any ideas on how I can ensure the chart is clear before I copy my image into it would be very appreaciated
DimDim oRange As Range
Dim oCht As Chart
Set oRange = Range("E3:N13")
Set oCht = Charts.Add
ActiveChart.Parent.Delete ' This is throwing an error (ie doesn't support)
oRange.CopyPicture xlScreen, xlPicture
oCht.Export Filename:="C:\Temp\test.png", Filtername:="PNG"