I am trying to export a chart using the code below, the loops change the data that is used to produce the chart:
Dim strFilename As String Dim strExt As String Dim lngProfile As Long Dim lngOption As Long For lngOption = 1 To 3 Range("nmOption") = Choose(lngOption, "Existing", "Option 4", "Option 5") For lngProfile = 1 To 4 Range("nmProfile") = "Profile " & lngProfile ActiveSheet.ChartObjects("Chart 13").Activate ActiveChart.ChartArea.Select strExt = "gif" strFilename = ThisWorkbook.Path & "\Images\" & _ Range("nmOption") & "_" & Range("nmProfile") & "." & strExt ActiveChart.Export strFilename, strExt Next lngProfile Next lngOption
Each export command creates a file with the correct name but no data (0kb in size) and a temporary file that is the correct file type (I have tried both jpg and gif).
I could try and copy the temporary file, but why does Excel not finish the job? I have tried to put a loop in and also added DoEvents after the export but no joy.