Mohd Reza
Mohd Reza

Reputation: 73

Copying/Pasting a range in high quality picture problem

Thank you for your time and I hope someone can answer this problem for me, I want to copy a range containing a chart and paste it in my dashboard, a user here named Patrick was kind enough to show me the way which works great, except that the picture being pasted shows shadows like the picture below and I don't know how to correct this, the code I'm using is this:

    ActiveSheet.Pictures.Delete
    Application.ScreenUpdating = True
    Application.CutCopyMode = False
    Worksheets("Weekly Sorted").Range("N1:AA37").CopyPicture xlScreen, xlBitmap
    Application.ScreenUpdating = False
    Sheets("Dash").Select
    Range("B5").Select
    ActiveSheet.Pictures.Paste.Select

Picture one is how the chart looks like... enter image description here

And this picture is how it gets pasted... enter image description here

I'm not very familiar with technical codes, so a simple solution to this problem is highly appreciated. I tried using xlprint and xlPicture options but the picture resolution obtained were horrible.

Thanking you all in advance.

EDIT:

Thank you Tony for the help, I wasn't very clear as I tried to oversimplify things before, my code above copies a whole range of charts, tables and other info from the calculation sheet over to the dashboard, depending on which radio button is pressed, like the new picture below, sometimes there are more than 10 charts, I'm using excel 2007, do you think I can use your code for everything I need?

enter image description here

Upvotes: 0

Views: 196

Answers (1)

Tony M
Tony M

Reputation: 1762

I made a chart which seems similar to yours from the data shown at A2:A9 on Sheet "1" and then ran the code below to produce a picture from the chart pasted on sheet "2"

Option Explicit
Sub copyChartPicture()
Dim ch As ChartObject
Dim sh1 As Worksheet, sh2 As Worksheet
Set sh1 = Worksheets("1")
Set sh2 = Worksheets("2")
For Each ch In sh1.ChartObjects
    ch.CopyPicture
    sh2.Activate
    sh2.Pictures.Paste
Next ch
End Sub

It looks identical as can be seen in the animated gif which shows me stepping through the code (click on it to get a higher quality image). I suggest you duplicate exactly what I've done to confirm it for yourself and then apply to your situation. enter image description here

Upvotes: 1

Related Questions