I have code that copies images from 1 workbook to another. Excel decides to stop the code once in a while with:
Error 1004 "PasteSpecial method of Range class failed"
Sometimes it successfully copies all images, but most of the time a few are left out (when on error resume next is set). If I choose "Debug" on the error and then press F8, the image is copied. (but on error resume next
does not have the same effect)
Other ways of copying images, like .CopyPicture
End result is the same.
'Code below is in a loop
vArr3 = Split(Cells(1, i).Address(True, False), "$")
t = vArr3(0)
Application.Goto Workbooks(BOM).Worksheets("Blad1").Range("a2")
Workbooks(BOM).Worksheets("Blad1").Shapes.Range(Array("Afbeelding " & im)).Select
Selection.Copy
Workbooks(Template).Worksheets("Sheet1").Activate
Application.Goto Workbooks(Template).Worksheets("Sheet1").Range(t & rs)
Workbooks(Template).Worksheets("Sheet1").Range(t & rs).Select
Workbooks(Template).Worksheets("Sheet1").Range(t & rs).PasteSpecial 'Error here
rs = rs + 5
im = im + 2
I expect Excel to always work 100% correctly. The images (and number of) that are left out is random.