All,
I have a graph that loops through all charts on one tab and then pastes the charts as pictures on another tab.
The code keeps getting hung up on a section, but the hangup is inconsistent. In other words, sometimes the code works fine, ohter times I get an error:
"Run time error 1004"
"An invlaid character was found in text character"
The code gets hung up on the CopyPicture line found below.
The inconsistency has me wondering if there is just something with Excel that it is hanging on something. Is there a way to kind of clear out some garbage that might be hanging around. If I close Excel and re-open the file, iot works perfectly a few times and then starts hanging up.
I have a graph that loops through all charts on one tab and then pastes the charts as pictures on another tab.
The code keeps getting hung up on a section, but the hangup is inconsistent. In other words, sometimes the code works fine, ohter times I get an error:
"Run time error 1004"
"An invlaid character was found in text character"
The code gets hung up on the CopyPicture line found below.
The inconsistency has me wondering if there is just something with Excel that it is hanging on something. Is there a way to kind of clear out some garbage that might be hanging around. If I close Excel and re-open the file, iot works perfectly a few times and then starts hanging up.
Code:
For i = 1 To intX
Range("A1").Select
ActiveSheet.ChartObjects(i).Activate
ActiveSheet.ChartObjects(i).Select
ActiveChart.ChartArea.Select
ActiveChart.CopyPicture Appearance:=xlPrinter, Size:=xlScreen, Format:= _
xlPicture
ActiveWindow.Visible = False
'Windows("Gildan Reporting Master_V2.xls").Activate
'ActiveChart.ChartArea.Select
Sheets("Graphs Final").Select
''Set the paste column (A or L)
If i Mod 2 <> 0 Then
mypastecol = 1
ElseIf i Mod 2 = 0 Then
mypastecol = 12
End If
''Set the paste row
If i Mod 1 = 0 And i > 2 Then
mypasterow = mypasterow + 18
ElseIf i Mod 2 <> 0 And i < 3 Then
mypasterow = mypasterow
End If
''Finally paste the chart as a picture
Cells(mypasterow, mypastecol).Select
ActiveSheet.Pictures.Paste.Select
Sheets("Graphs").Select
Next
Last edited by a moderator: