How to copy a chart from Excel to PowerPoint?

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".

enter image description here

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 .