怎样关闭PowerPoint进程。急~,帮帮忙啊,要交差了。
通过下面代码打开PPT后。
ppt = (PowerPoint.Presentation) System.Runtime.InteropServices.Marshal.BindToMoniker(PPTfilename);
string sFile = PPTfilename.Substring(PPTfilename.LastIndexOf("\\")+1);
ppt.Application.Visible = Office.MsoTriState.msoCTrue;
UCOMIConnectionPointContainer oConnPointContainer = (UCOMIConnectionPointContainer) ppt.Application;
// Get the GUID of the EApplication interface.
Guid guid=typeof(PowerPoint.EApplication).GUID;
// Find the connection point.
oConnPointContainer.FindConnectionPoint(ref guid,out m_oConnectionPoint);
// Call Advise to sink up the connection.
m_oConnectionPoint.Advise(this,out m_Cookie);
为什么叉掉POWERPOINT窗口后,总是无法关闭(窗口没有了,但进程依然存在)。
[DispId(2004)]//处理关闭事件
public void PresentationClose(PowerPoint.Presentation Pres)
{
object missing = System.Reflection.Missing.Value;
ppt.SaveAs(PPTfilename,PowerPoint.PpSaveAsFileType.ppSaveAsPresentation,Office.MsoTriState.msoCTrue);
ppt.Close();
m_oConnectionPoint.Unadvise(m_Cookie);
System.Runtime.InteropServices.Marshal.ReleaseComObject(ppt);
GC.Collect();
ppt = null;
}
还有就是在关闭EXCEL,和WORD里面有个属性设置可以改是否弹出保存提示,但PowerPoint怎么没看到这个属性啊。