如何将图表从Excel复制到PowerPoint? [英] How to copy a chart from Excel to PowerPoint?
问题描述
有没有办法将excel电子表格中的图表复制到powerpoint,保留原始格式和嵌入数据?关于以编程方式复制粘贴图表已经有
可下载的文档包含每个Office应用程序的 idMSO
参数:
http://www.microsoft.com/en-us/下载/ details.aspx?displaylang = en&id = 6627
注意:如果你想用粘贴 .ExecuteMso
可能需要检查形状是否已经粘贴,因为 .ExcecuteMso
是异步的(宏不不知道什么时候完成)。另一个问题显示了如何等待完成 。
Is there any way I could copy a chart from an excel spreadsheet to a powerpoint, preserving the original formatting and embedding the data? There was already a question about copy pasting charts programmatically. However, there was nothing said about data embedding
The biggest problem is embedding the data. As far as I know data embedding requires recreating the chart from the beginning in the power point. (PS: By embedding i do not mean linking to an external excel file.)
What you need to do is invoke the PasteSpecial "Keep Source Formatting and Embed Workbook".
Assume you have already created the charts, and the slides, placeholders/etc., and you have already copied the chart and navigated to the destination slide, and that you have an object like PPTApp
to represent the PowerPoint.Application
object.
Instead of using the Shapes.PasteSpecial
method, you can do this:
PPTApp.CommandBars.ExecuteMso "PasteExcelChartSourceFormatting"
This does not create a link to the Excel document, it embeds a local copy of the document in the PowerPoint Presentation. I think I understand this is your requirement.
Update from comments
Documentation on the ExecuteMso
method:
http://msdn.microsoft.com/en-us/library/office/ff862419.aspx
Downloadable document containing the idMSO
parameters for each Office Application:
http://www.microsoft.com/en-us/download/details.aspx?displaylang=en&id=6627
NOTE: If you want to do something with the pasted chart after .ExecuteMso
you may need to check if the shape is already pasted because .ExcecuteMso
is asynchronous (the macro doesn't know when it's finished). Another question shows you how to wait for its completion .
这篇关于如何将图表从Excel复制到PowerPoint?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!