且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用pastepecial到图表作为位图粘贴到另一个工作表中的VBA

更新时间:2022-12-12 08:26:09

这将无需激活工作/选择Sheet2中:

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

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

This will work without needing to activate/select Sheet2:

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