How to copy a chart from Excel to PowerPoint?

大兔子大兔子 提交于 2019-11-26 20:59:18
David Zemens

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 .

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