Unable to get the Paste property of the Picture Class VBA Excel

2.3k views Asked by At

I'm working on a macro to move data from one workbook into another which includes a few charts. To prevent the new workbook from becoming broken, I want to paste these charts as pictures.

I'm encountering errors at the point in my code where I copy and paste the graphs between the two workbooks, but the errors keep happening on different lines of my code (typically on a copy or paste operation but generally on different lines concerning different charts). One of the errors reads "Unable to get the Paste property of the Pictures Class." The other one reads "Method 'Copy' of object 'ChartArea' Failed."

If I enter debug mode and press F5 to continue to run the code, the macro manages to complete the operation that gave the error as well as finish the rest of the code without a problem.

'Copy/Paste Chart 4
ActiveSheet.ChartObjects("Chart 4").Activate
ActiveChart.ChartArea.Copy
Windows(2).Activate
Range("Q3").Select
ActiveSheet.Pictures.Paste.Select

'Copy/Paste Chart 5
ActiveSheet.ChartObjects("Chart 4").Activate
ActiveChart.ChartArea.Copy
Windows(2).Activate
Range("Q3").Select
ActiveSheet.Pictures.Paste.Select

...

'Copy/Paste Chart n
Windows(2).Activate
ActiveSheet.ChartObjects("Chart n").Activate
ActiveChart.ChartArea.Copy
Windows(2).Activate
Range("X3").Select
ActiveSheet.Pictures.Paste.Select
0

There are 0 answers