Manipulate copied image of chart object after the copy

higrm

New Member
Joined
Nov 5, 2014
Messages
47
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.
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:

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Not sure if I did a really bad job of explaining or what I am asking for isn't possible. If it is the explanation part, let me try again.


5Krtx15.jpg



Code:
Sub copyGraphAsImage()
    ActiveChart.ChartArea.Copy
    Range("E9").Select
    ActiveSheet.Pictures.Paste.Select
    Selection.ShapeRange.IncrementLeft 2.5
    Selection.ShapeRange.IncrementTop 2.75
End Sub

What I want is to not have to select cell E9 or to have the graph selected in order to move it. Normally, the image will be placed on a second tab and I do not want to activate that second tab to manipulate this image or any of the other graphs I plan on adding to that second tab. It is all supposed to happen without "Select" or "Activate". Can this be done?

Thanks for any input. Any.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,910
Messages
6,175,318
Members
452,634
Latest member
cpostell

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top