How to use pastepecial to paste a chart as bitmap

2019-06-10 03:54发布

问题:

Is there a way to use the pastspecial method to paste a copyied chart as a bitmap to another worksheet. Currently this is my syntax-

PasteSheet.PasteSpecial (Format:="Bitmap", Link:=False, DisplayAsIcon:=False)

Where PasteSheet is the other worksheet i want to paste to. Currently with this code, it is only pasting in the active sheet. Do i have to use select to copy then select the page i want to paste to, then change back to the sheet I copied from? I hope not as I have a lot of sheets haha.

Thank you

Edit: I have found out that if I Copy the chart as a shape rather than a chartobject I can use the pasteSpecial method to paste to another sheet. That being said it now pastes charts into one another creating one mega chart haha.

GraphSheet.Shapes(chtName).Copy 
PasteSheet.PasteSpecial Format:="Microsoft Office Drawing Object", Link:=False , _
     DisplayAsIcon:=False

回答1:

This will work without needing to activate/select Sheet2:

Sheet1.ChartObjects(1).Chart.CopyPicture
Sheet2.Paste


回答2:

Do i have to use select to copy then select the page i want to paste to, then change back to the sheet I copied from?

Yes - the sheet you paste into must be active. Use Sheets("mytargetname").Select - just using Activate isn't enough...

If you set

Application.ScreenUpdating = False

your screen won't flash while you do this...