以编程方式复制具有源格式的形状 (PowerPoint 2007)
我需要能够在 PowerPoint 2007 中以编程方式将形状(图表、表格等)从一张幻灯片复制到另一张幻灯片,并保持其原始颜色。源幻灯片和目标幻灯片位于具有不同主题的不同演示文稿中。
这些形状可能很复杂并且包含很多颜色,例如图表、表格等。目标幻灯片必须保持其主题,因此我不能简单地复制整个原始幻灯片 colorScheme。
在 PowerPoint 中手动复制形状时,我可以选择“保留源格式”。这将复制形状的所有原始颜色,将主题颜色转换为绝对 RGB 值。
以编程方式执行此操作的最简单方法是什么?
I need to be able to copy shapes (chart, table, etc.) programmatically from one slide to another in PowerPoint 2007 keeping their original colors. The source and destination slides are in different presentations which have different themes.
These shapes might be complex and include a lot of colors, e.g., charts, tables, etc. The destination slide must maintain its theme, so I cannot simply copy the entire original slide colorScheme.
When copying a shape manually in PowerPoint, I get an option to "Keep Source Formatting". This copies all the original colors of the shape, converting theme colors into absolute RGB values.
What is the simplest way to do this programmatically?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要转到幻灯片并使用 Application.CommandBars.ExecuteMso
如果之后不需要返回到之前选择的幻灯片,则可以跳过 DoEvents 和对 Application.CommandBars.ExecuteMso
的第二次调用 看起来像新形状在粘贴后有时会有点倾斜,因此我获取了对第二张幻灯片的 Shapes 集合中最后一个形状的引用,并复制原始形状的位置。
至少在我的机器上,如果没有 DoEvents,宏在执行时不会执行任何操作(但如果我单步执行它,它就会起作用)。
You need to go to the slide and use Application.CommandBars.ExecuteMso
If you don't need to return to the previously selected slide afterwards, you can skip DoEvents and the second call to Application.CommandBars.ExecuteMso
It seemed like the position of the new shape was sometimes a little bit skewed after pasting, so I obtain a reference to the last shape in the Shapes collection of the second slide and copy the position of the original shape.
At least on my machine, without DoEvents, the macro would do nothing when I executed it (but it would work if I stepped through it).