How to use pastepecial to paste a chart as bitmap to another sheet in vba

混江龙づ霸主 提交于 2019-12-23 04:33:50

问题


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...



来源:https://stackoverflow.com/questions/14801459/how-to-use-pastepecial-to-paste-a-chart-as-bitmap-to-another-sheet-in-vba

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!