public bool PPTOpen(string path) { filepath = path; filename = Path.GetFileName(path); if (this.objApp != null) { return(true); } if (Global.getPPTMaximize()) { minisizeProc(); } try { //TODO: 需要将Form12关闭否? if (Form1.f12 != null) { Form1.f12.Hide(); } //显示桌面 //Type oleType = Type.GetTypeFromProgID("Shell.Application"); //object oleObject = System.Activator.CreateInstance(oleType); //oleType.InvokeMember("ToggleDesktop", BindingFlags.InvokeMethod, null, oleObject, null); objApp = new POWERPOINT.Application(); objPresSet = objApp.Presentations.Open(filepath, OFFICECORE.MsoTriState.msoFalse, OFFICECORE.MsoTriState.msoFalse, OFFICECORE.MsoTriState.msoFalse); objSlides = objPresSet.Slides; pageTotal = objPresSet.Slides.Count; objSSS = this.objPresSet.SlideShowSettings; objSSS.LoopUntilStopped = MsoTriState.msoTrue; objSSS.Run(); //最大化当前窗口 maximizePPTProc(); if (pageCurrent > 0) { //GotoPage(pageCurrent); } else { pageCurrent = 1; pageLast = 1; } Log.Info("PPTOpen ok."); return(true); } catch (Exception ex) { int errorcode = 0; var w32ex = ex as Win32Exception; if (w32ex == null) { w32ex = ex.InnerException as Win32Exception; } if (w32ex != null) { errorcode = w32ex.ErrorCode; } Log.Error("PPTOpen exception. " + ex.Message + ", errorcode=" + errorcode);//Error HRESULT E_FAIL has been returned from a call to a COM component. this.objApp.Quit(); objApp = null; MessageBox.Show("打开" + filename + "失败,请检查该文件!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return(false); } finally { } }