Happy Easter!
I have a chart on one sheet and need to copy an image onto a second sheet. I copy the image into a cell and then want to nudge it slightly. My problem is being able to identify the chart I want to manipulate after the copy operation. I copied some code for a function that gave me the id of the last picture I created, which works, but I don't want to need to do that. What is wrong with my Set Pic line which is causing a 424 Object required error? The chart image is being copied to the correct place before the error stops the macro.
Macro stops on the last line.
Using the commented out line above the line where I am getting the error, and then using a function to get the id of the last picture on tab Graph2, does allow me to make my tweaks to the copied image, but seems clunky.
I prefer to write my code as compact as possible. Even the "cht.CopyPicture" line seems like it could be skipped by tacking ".cht" to the end of a Range Method and avoid the clipboard entirely.
Is it something obvious? Would you recommend a different method to copy the image of the chart onto the second tab?
Thanks in advance,
Higrm
I have a chart on one sheet and need to copy an image onto a second sheet. I copy the image into a cell and then want to nudge it slightly. My problem is being able to identify the chart I want to manipulate after the copy operation. I copied some code for a function that gave me the id of the last picture I created, which works, but I don't want to need to do that. What is wrong with my Set Pic line which is causing a 424 Object required error? The chart image is being copied to the correct place before the error stops the macro.
Code:
Set cht = Sheets("Graph1").Shapes.AddChart2(, xlRadar, Range("B2").Left + 2, Range("B2").Top + 4, 180)
cht.SetSourceData Source:=r2, PlotBy:=xlRows
Dim pic As Object
cht.CopyPicture
' Sheets("Graph2").Range("B2").PasteSpecial Operation:=xlPasteSpecialOperationAdd
Set pic = Sheets("Graph2").Range("B2").PasteSpecial(, xlPasteSpecialOperationAdd)
Macro stops on the last line.
Using the commented out line above the line where I am getting the error, and then using a function to get the id of the last picture on tab Graph2, does allow me to make my tweaks to the copied image, but seems clunky.
I prefer to write my code as compact as possible. Even the "cht.CopyPicture" line seems like it could be skipped by tacking ".cht" to the end of a Range Method and avoid the clipboard entirely.
Is it something obvious? Would you recommend a different method to copy the image of the chart onto the second tab?
Thanks in advance,
Higrm
Last edited: