Note that there are some explanatory texts on larger screens.

plurals
  1. POPowerPoint Launched via C# does not Quit
    primarykey
    data
    text
    <p>Hey I'm automating PowerPoint and Excel from a C# WinForms application; what I do is read slides from PowerPoint and save them in Excel and then quit both apps. Excel quits successfully but PowerPoints doesn't quits. The problem is when I convert first time it doesnt quits, but when I convert again it does.</p> <p>Here is my code</p> <pre><code>try { PowerPoint.Application ppApp; PowerPoint.Presentation ppPres; List&lt;Company&gt; companies = new List&lt;Company&gt;(); ppApp = new PowerPoint.Application(); ppApp.Visible = Microsoft.Office.Core.MsoTriState.msoTrue; ppApp.WindowState = Microsoft.Office.Interop.PowerPoint.PpWindowState.ppWindowMinimized; ppPres = ppApp.Presentations.Open(fileTxtBox.Text, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoTrue); int slides = ppPres.Slides.Count; for (int slide = 1; slide &lt;= slides; slide++) { int rows = 1; PowerPoint.Cell cell; int shape = 1; for (; shape &lt; ppPres.Slides[slide].Shapes.Count; shape++) { if (ppPres.Slides[slide].Shapes[shape].HasTable == Microsoft.Office.Core.MsoTriState.msoTrue) { cell = ppPres.Slides[slide].Shapes[shape].Table.Cell(1, 1); if (cell.Shape.TextFrame.TextRange.Text.Trim().ToLower().Contains("realized")) { rows = ppPres.Slides[slide].Shapes[shape].Table.Rows.Count; break; } } } Company comp = new Company(rows); InitializeCompany(ref comp, ppPres.Slides[slide]); companies.Add(comp); } SaveInExcel(companies); ppPres.Close(); ppPres = null; ppApp.Quit(); ppApp = null; return; } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { GC.Collect(); GC.WaitForPendingFinalizers(); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload