title: How can I add a macro to a Word 2010 or PowerPoint 2010 chart?
body: <p>In PowerPoint 2010 or Word 2010, when I choose Insert -> Chart, it creates a new chart with an Excel worksheet for the data.</p>
  
  <p>If I add a macro to the Excel worksheet, this seems to be discarded when I close the worksheet and re-open it.</p>
  
  <p>However, it <em>is</em> possible to have a chart with macros, because I also have some Word documents &amp; PowerPoint presentations that I created in Office 2003, which had embedded Excel charts with macros.  When I converted those to Office 2010, they look just like "normal" Office 2010 charts, but the macros are preserved.</p>
  
  <p>It looks to me like the embedded chart that gets created when you choose Insert -> Chart is in the "pptx" format rather than the "pptm" format, and so macros are not saved.</p>
  
  <p>(If I query ActiveWorkbook.FileFormat, I get "51", which is "Open Xml Spreadsheet";  this is indeed "pptx", as opposed to "Open Xml Spreadsheet with Macros", which is "52").</p>
  
  <p>How can I insert a chart with the "pptm" behavior? Or change the behavior of an existing chart?</p>
  
  <hr>
  
  <p>NOTE: I do not want to insert a chart "object", since this means that the chart is not editable within the host application (it merely inserts an Excel chart that you need to "open" in order to edit it).</p>
  
  <hr>
  
  <p>Let me give you a head start... I can achieve what I want by the following method:</p>
  
  <ol>
  <li>Create a new document in Word (or PowerPoint).</li>
  <li>Save the document as a 97-2003 document (which forces it into compatibility mode).</li>
  <li>Insert a chart using Insert->Object->Microsoft Excel Chart. This embeds an old-style Excel chart.</li>
  <li>Open the embedded chart by right-click->Open, and add a macro.</li>
  <li>Close the chart, then choose File->Info and use the Compatibility Mode "Convert" button to convert the document into an Office 2010 document.</li>
  </ol>
  
  <p>Now you have a "native" Word or PowerPoint 2010 chart, which you can edit directly in Word or PowerPoint. If you click on the chart and choose Chart Tools->Design->Edit Data, then the Excel worksheet that opens has the macros you created in step 4. Success!</p>
  
  <p>Now, does anyone have a simpler way?</p>