0

I was wondering how to export graphs from excel instead of using Snipping tool ... I found some code there and there. But I remain stuck with the following error :

"Run-Time error '424'": Object required 
(same as on link 2) but I can't figure out where does it come from ...

Any thoughts where to start by ?

Sub SaveAllCharts()

Dim SaveToDirectory As String

Dim myChart As Chart

SaveToDirectory = ActiveWorkbook.Path & "\Images\"

MsgBox ("Saved Directory:" + SaveToDirectory)

For Each myChart In ActiveWorkbok.Charts MsgBox (OK) myChart.Export SaveToDirectory & myChart.Name & ".png", PNG Next

End Sub
CLR
  • 21
  • 4

1 Answers1

0

There were a couple of errors in your code Option Explicit is a great way to find typos as a couple people said.

Another error was with on your myChart.Export (SaveToDirectory & myChart.Name & ".png", PNG) line. You do not need the filterName so myChart.Export (SaveToDirectory & myChart.Name & ".png") is perfectly ok for this occasion

Full Code:

Option Explicit
Sub SaveAllCharts()

Dim SaveToDirectory As String

Dim myChart As Chart

SaveToDirectory = ActiveWorkbook.Path

MsgBox ("Saved Directory:" + SaveToDirectory)

For Each myChart In ActiveWorkbook.Charts
myChart.Export (SaveToDirectory & myChart.Name & ".png")
Next myChart

End Sub

I have tested this code and it works on my pc if you get any issues i will try to help you out

Hopes this helps

Sebic0
  • 40
  • 8
  • Thanks it works pretty well. My only error - other than Option Explicit and miswriting in Workbook - was to have ', PNG)' at the end ? What is the meaning of that ? – CLR Jun 26 '18 at 12:50