Hello All,
So I have what seems to be an insanely easy coding question, but it's driving me crazy. So I have this code that selects a chart and then copies it, and I wanted to make it save the chart as a picture instead of copying it. Here is the copying code:
Code:
Dim objChart As ChartObject
On Error Resume Next
Set objChart = ActiveSheet.ChartObjects(1).Select
Selection.CopyPicture _
Appearance:=xlScreen, Format:=xlBitmap
That code works fine, so I thought I'd do
Code:
Dim objChart As ChartObject
On Error Resume Next
Set objChart = ActiveSheet.ChartObjects(1).Select
Selection.Export Filename:="C:\test.jpg", FilterName:="jpg"
Nothing ever shows up in C:\ or any other folder I've tried. I also wondered if I needed to set objChart as something else so that it as already selected, based on something I saw online:
Code:
Dim objChart As ChartObject
Dim slcChart As ChartObject
On Error Resume Next
Set objChart = ActiveSheet.ChartObjects(1).Select
Set slcChart = ActiveSheet.ChartObjects(1)
If ActiveChart Is Nothing Then
MsgBox "No charts have been detected on this sheet", 0
End If
slcChart.Export Filename:="C:\test.jpg", FilterName:="jpg"
Still doesn't work. No error messages but no file either. I only have one chart in my Excel file. Can you see anything I might have done wrong?
-Dave