Reputation: 21
I get Run-time error '1004' when trying to copy a range of cells and doing a paste as a picture.
I have 1 Excel file that has 2 sheets:
(I created this small Excel only for replication purposes as I have the issue in a much bigger Excel file.)
I have a macro to copy the range of cells that contains the Pivot Table and paste it as a picture.
The macro is running correctly with no errors in my laptop and in other colleagues' laptops. Some colleagues are getting the error in their laptops.
We all are using:
Sub Macro4()
Dim ws As Worksheet
Set ws = Sheets("CS - Pivot Tables")
With ws
.Activate
.Range("B2:D13").Copy
.Range("L2").Select
.Pictures.Paste
End With
Application.CutCopyMode = False
Range("A1").Select
End Sub
***** the macro stops on .Pictures.Paste
Upvotes: 2
Views: 3235
Reputation: 43595
Can you try something like this:
Sub Macro4()
Dim ws As Worksheet
dim pic as picture
Set ws = Sheets("CS - Pivot Tables")
With ws
.Activate
.Range("B2:D13").Copy
.Range("L2").Select
set pic = .pictures.paste
End With
Application.CutCopyMode = False
Range("A1").Select
End Sub
(Your code is not formatted, but I am guessing I did it right).
Upvotes: 1
Reputation: 2666
You need to use a different copy to copy pictures:
Sub Macro4()
Dim ws As Worksheet
Set ws = Sheets("CS - Pivot Tables")
With ws
.Activate
.Range("B2:D13").CopyPicture Appearance:=xlScreen, Format:=xlPicture
.Range("B1").Select
.Paste
End With
Range("A1").Select
End Sub
Upvotes: 3