如何将Shape复制到另一个工作表(而不是图片)? [英] How to copy a Shape to another worksheet (not as a picture)?

查看:198
本文介绍了如何将Shape复制到另一个工作表(而不是图片)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用Excel VBA时遇到了麻烦(再一次...).

I'm having a bit of a trouble (once again...) with Excel VBA.

我只想将一个工作表中的Shapes(实际上是具有预定义布局的模板"形状)复制到另一个工作表中.

I just want to copy Shapes (which are in fact "templates" shapes, with pre-defined layout) from a Worksheet to another Worksheets.

当我记录宏时,这是生成的VBA代码:

When I record a macro, this is the generated VBA code :

    Sheets("Layout").Select
    ActiveSheet.ChartObjects("CHART_TEMPLATE").Activate
    ActiveChart.ChartArea.Copy
    Sheets("Example").Select
    Range("A1").Select
    ActiveSheet.Paste

当然,我想摆脱所有".Select"方法的性能问题.因此,我不能Select范围,也不能使用ActiveSheet.Paste

Of course, I want to get rid of all ".Select" methods, for performance issue. For this reason, I can't Select a range, neither use ActiveSheet.Paste

不幸的是,Paste方法仅适用于Worksheet对象(如ActiveSheet.Paste),因此我不得不使用PasteSpecial对象的PasteSpecial方法.

Unfortunately, the Paste method only exists for Worksheet objects (like ActiveSheet.Paste), so I had to use the PasteSpecial method of Range objects.

这是我的代码:

    ThisWorkbook.Sheets("Layout").ChartObjects("CHART_TEMPLATE").Copy
    ThisWorkbook.Sheets("Example").Range("A1").PasteSpecial Paste:=xlPasteAll

但是,PasteSpecial方法将Shapes复制为图片... 当然,我不需要图片,因为我必须用数据填充这些Charts.

But, the PasteSpecial method copies Shapes as pictures... Of course I don't want pictures, because I have to populate those Chartswith data.

有人在这里有线索吗?

感谢,

推荐答案

Paste方法可以将目标作为参数.你尝试过类似的东西吗?

The Paste method can take a destination as an argument. Have you tried something like this?

ThisWorkbook.Sheets("Example").Paste Destination:=ThisWorkbook.Sheets("Example").Range("A1")

这篇关于如何将Shape复制到另一个工作表(而不是图片)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆