Hi,
I'd like to be able to save all the workbook charts as images.
The folder structure would ideally be like this:
C:\Users\Pictures\Workbook Name\Sheet Name\Chart Title Name
Some code is below which I've started on but am a bit stuck.
Any help would be appreciated thanks.
I'd like to be able to save all the workbook charts as images.
The folder structure would ideally be like this:
C:\Users\Pictures\Workbook Name\Sheet Name\Chart Title Name
Some code is below which I've started on but am a bit stuck.
Any help would be appreciated thanks.
VBA Code:
Sub ExportSheetCharts()
'Create a variable to hold the path and name of image
Dim CurrentSheet As Worksheet
Dim cht As ChartObject
Dim strUserName As String
Dim subfolder As String
Dim strFileFullName As String
strUserName = Application.UserName
subfolder = ActiveSheet.Name
strFileFullName = ThisWorkbook.FullName
If Len(Dir("C:\Users\" & strUserName & "\Pictures\" & strFileFullName & "\")) = 0 Then
MkDir ("C:\Users\" & strUserName & "\Pictures\" & strFileFullName & "\")
End If
'Export the chart
For Each sht In ActiveWorkbook.Worksheets
For Each cht In ActiveSheet.ChartObjects
cht.Chart.Export "C:\Users\" & strUserName & "\Pictures\" & strFileFullName & "\" & subfolder & cht.Chart.ChartTitle.Text & x & ".jpg"
x = x + 1
Next cht
Next sht
End Sub
Last edited: