Reputation: 1
I create a new excel file I create two tabs. I record a macro where I select a range of cells (Does not matter the size) on Sheet1 then select copy as picture. I then paste that image on Sheet 2. I stop the recording and delete the image and go back to Sheet 1. I then try to play the macro and i get Runtime Error 1004
. Does Anyone know how to fix my excel?
I am happy to share my code but did not think it was necessary sense it seems to be more a core problem in excel.
Adding Code Below.
Sub CopyData(tRange As String, SheetName As String)
Worksheets(SheetName).Range(tRange).CopyPicture xlPrinter, xlPicture
End Sub
Sub Test()
Call CopyData("B2:I31", "Sheet1")
End Sub
Adding new Details
In my office we have 4 macs. All of them had started requesting updating to excel 16.11.1 . This had been done on two mine and One other computer. Today I tried my code on one of the machines that does not have 16.11.1 and it worked. I updated to 16.11.1 and it stopped working. I feel confident that 16.11.1 is the problem.
Upvotes: 0
Views: 558
Reputation: 1
The Issue was caused by office being update. I followed Microsofts instructions for downgrading and it solved the issue. Thanks to all those who responded and gave support.
Upvotes: 0
Reputation: 2628
This will accomplish what you are trying to do; set your worksheets and ranges as variables. You do not need to add the constants for CopyPicture
if you will be using the defaults, which are: xlScreen
and xlPicture
...
Sub CopyData()
Dim ws1 As Worksheet
Dim ws2 As Worksheet
Dim Rng1 As Range
Dim Rng2 As Range
Set ws1 = Sheets("Sheet1")
Set ws2 = Sheets("Sheet2")
Set Rng1 = ws1.Range("B2:I31")
Set Rng2 = ws2.Range("A1") 'change the cell ref as needed
Rng1.CopyPicture xlPrinter, xlPicture
ws2.Paste Destination:=Rng2
End Sub
Upvotes: 1