Hello dear VBA-specialists,
im an beginner in VBA-programming and came to the point, where i donīt know what to do next. My code is perfectly working when i save a graph (to jpg) to my Desktop. When i try to save anotherone (it is important to know that you can display different data-sets in one single graph with the same Name: e.g. diagramm5) the just saved Chart is overwritten. I can tell that the Problem can be solved by just adding a sequential numbering to the code, but my VBA skills are waaay to low
I hope anyone could help me. Would be great! Thankns in advance!
Here is my code; please donīt be shocked, im just happy that it works somehow 
Sub Chart_SavetoJPG()
Dim objShell As Object
Dim objWindowsFolder As Object
Dim strWindowsFolder As String
Dim objSheet As Excel.Worksheet
Dim objChartObject As ChartObject
Dim objChart As Excel.Chart
'Select a Windows folder
Set objShell = CreateObject("Shell.Application")
Set objWindowsFolder = objShell.BrowseForFolder(0, "Select a Windows folder:", 0, "")
If Not objWindowsFolder Is Nothing Then
strWindowsFolder = objWindowsFolder.self.Path & "\"
Set objSheet = ThisWorkbook.Worksheets("WEO")
If objSheet.ChartObjects.Count > 0 Then
For Each objChartObject In objSheet.ChartObjects
Set objChart = objChartObject.Chart
objChart.Export strWindowsFolder & objChart.Name & ".jpg"
Next
End If
'Open the windows folder
Shell "Explorer.exe" & " " & strWindowsFolder, vbNormalFocus
End If
End Sub
Have a nice day,
Jim
Bookmarks