如何关闭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;
}