【发布时间】:2013-10-29 16:05:05
【问题描述】:
我有一些 c# 代码可以打开一个 Powerpoint 幻灯片,刷新图表,然后退出。
这很好用,除非用户已经打开了一个 Powerpoint 幻灯片,在这种情况下,一旦 exe 运行,它将关闭他们现有的会话(丢失他们可能所做的任何更改!)。
所以,问题是如果您在后台打开了 PPT,运行我的 EXE,它运行以下代码(打开模板,刷新一些图表,保存和关闭),在应用程序退出时它会处理变量 ppApp似乎关闭了所有正在运行的 PPT。
即使我省略 ppApp.Quit(); 也会出现这种情况
PowerPoint.Application ppApp = new PowerPoint.Application();
PowerPoint.Presentation ppPres = ppApp.Presentations.Open(MITemplate, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoFalse);
//refresh graphs
foreach(PowerPoint.Slide sl in ppPres.Slides)
{
foreach (PowerPoint.Shape sh in sl.Shapes)
{
if (sh.Type.Equals(Microsoft.Office.Core.MsoShapeType.msoLinkedOLEObject))
{
sh.LinkFormat.SourceFullName = XLTemplate + sh.LinkFormat.SourceFullName.Substring(sh.LinkFormat.SourceFullName.LastIndexOf("\\") + 1);
sh.LinkFormat.Update();
}
}
}
ppPres.SaveAs(outputFilename);
ppPres.Close();
ppApp.Quit();
【问题讨论】:
标签: c# process interop powerpoint kill