In PowerPoint 2010 or Word 2010, when I select Insert → Chart, it creates a new chart with an Excel worksheet for the data.
If I add a macro to the Excel worksheet, it seems to be undone when I close the worksheet and open it again.
However, it is possible to have a chart with macros because I also have Word documents and PowerPoint presentations that I created in Office 2003 that had Excel built-in graphs with macros. When I converted them to Office 2010, they look just like the “regular” Office 2010 graphics, but the macros are saved.
It seems to me that an inline chart is created when you select Insert → Chart in the "pptx" format, and not in the "pptm" format, and therefore macros are not saved.
(If I request ActiveWorkbook.FileFormat, I get "51", that is, "Open Xml Spreadsheet", it really is "pptx", unlike "Open Xml Spreadsheet with Macros", which is "52").
How to insert a diagram with the behavior of "pptm"? Or change the behavior of an existing chart?
NOTE. I don’t want to insert the “object” diagram, since this means that the diagram is not being edited in the host application (it just inserts the Excel diagram that needs to be “opened” to be edited).
Let me give you a start ... I can achieve what I want with the following method:
- Create a new document in Word (or PowerPoint).
- Save the document as document 97-2003 (which forces it to work in compatibility mode).
- Insert a chart using Insert-> Object-> Microsoft Excel Chart. It embeds an old-style Excel chart.
- Open the built-in diagram with the right mouse button-> Open and add a macro.
- Close the chart, then select "File-> Information" and use the "Convert" button in compatibility mode to convert the document to an Office 2010 document.
Now you have a “native” Word or PowerPoint 2010 chart that you can edit directly in Word or PowerPoint. If you click on the chart and select "Chart Tools" → "Design → Change Data", will the Excel sheet that you created in step 4 open. Success!
Does anyone now have an easier way?