title: Problem with generated PowerPoint Presentation Charts in C# with office.interop
body: <p>I am working on a small <code>C#</code> project, that creates a <code>PowerPoint</code> presentation from <code>Jira</code> data. The program worked fine, until like 2 weeks ago a new error occurred (no changes to coding where made in this time).</p>
  <p>What I am doing exactly is: I have a <code>PowerPoint</code> Template with a pie chart. I want to edit the Data of the pie chart in my program and at the end I save the presentation as new presentation in a folder the user specified.</p>
  <p>The bug that occurs is the following: The data shows correctly in the PPT presentation and die pie chart also works. However, if you right klick the pie chart and select &quot;edit data&quot;, die chart resets to the values specified in the template file (names are reset and values also change to &quot;1&quot;, like it is in my template). This is a clearly new behavior (it never happened since 2 weeks ago).</p>
  <p>The code I use to edit the data behind the pie chart looks like this:</p>
  <pre><code>            // using this libraries to acces powerpoint / excel:
              using PowerPoint = Microsoft.Office.Interop.PowerPoint;
              using Excel = Microsoft.Office.Interop.Excel;
  
              PPTPres.Slides[DiagrammPos[0]].Shapes[DiagrammPos[1]].Chart.ChartData.Activate();
              Excel.Workbook ExcelWB = (Excel.Workbook)PPTPres.Slides[DiagrammPos[0]].Shapes[DiagrammPos[1]].Chart.ChartData.Workbook;
              Excel.Application ExcelApp = ExcelWB.Application;
              ExcelApp.Visible = false;
              Excel.Worksheet DiagData = (Excel.Worksheet)ExcelWB.Worksheets[1];
  
              // example how DiagData is used in the programm:
              DiagData.Cells[Count, 1].Value = FileSet.GetName();
              DiagData.Cells[Count, 2].Value = TimeTotal;
  </code></pre>
  <p>I tried to manually save the excel workbook - object like this but I get an exception if I try to do this:</p>
  <pre><code>        try
          {
              ExcelWB.Save();
          } catch (Exception e)
          {
              Console.WriteLine(e.Message);
          }
  </code></pre>
  <p>The Exception is a HRESULT:0x800A03EC - Exception. It looks like this:</p>
  <p><a href="https://i.stack.imgur.com/nRQDb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nRQDb.png" alt="Screenshot of the Exception" /></a></p>
  <p>For reference, here are some screenshots of the behavior in the <code>PowerPoint</code> presentation:</p>
  <p>Diagram after my program ran (everything looks good):</p>
  <p><a href="https://i.stack.imgur.com/bwwRw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bwwRw.png" alt="Diagram after my program ran (everything looks good)" /></a></p>
  <p>Screenshot of the option, that destroys everything:</p>
  <p><a href="https://i.stack.imgur.com/McegV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/McegV.png" alt="Screenshot of the option, that destroys everything" /></a></p>
  <p>Screenshot of the reset chart:</p>
  <p><a href="https://i.stack.imgur.com/FmBtM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FmBtM.png" alt="Screenshot of the reset chart" /></a></p>
  <p>Is there a way to prevent the pie chart from being reset?</p>
  <p>EDIT:
  I tried multiple things, but nothing worked out:</p>
  <ul>
  <li>Refreshing the Diagramm after all changes are done.</li>
  <li>Closing the <code>ExcelWB - Object</code> with the <code>.close()</code> method</li>
  <li>Changing the Template (it resets to the changed template if i do this)</li>
  <li>Saving the changed Template before saving the PPT as new Presentation (still resets everything)</li>
  </ul>
  <p>I am realy stuck with this issue.</p>