'VBA - Error 1004 - CopyPicture of method class failed

i need some help with my code. I wrote a macro which copies many tables as pictures from different Excel files to PowerPoint, but sometimes it works perfectly, and sometimes appears Error 1004 - CopyPicture of method class failed. Here is my code:

Sheets("List1").Select
' group chart
ActiveSheet.Outline.ShowLevels RowLevels:=0, ColumnLevels:=1
' select cells to be copied to PowerPoint:
Range("A1:X83").Select
' copy cells:
Selection.CopyPicture Appearance:=xlScreen, Format:=xlPicture
' paste to PowerPoint:

pptSld.Shapes.Paste.Select

I found that for someone was helpful inserting Sheets("List1"). before Range("A1:X83").Select, but it didn't help. I have this problem at work, where I'm using Office 2010. At home I have Office 2016 and code works perfectly.

Do you have any ideas, how to make it work without any errors?



Solution 1:[1]

Check your references to make sure that you're calling the correct library.

Tools > References

Not sure which on you need, but make sure you have Microsoft Powerpoint xx.x blah blah blah checked.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 TheKirkwoods