我想打开ppt [英] I am trying to open ppt

查看:62
本文介绍了我想打开ppt的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正尝试使用以下代码从c:\ myppts\first.ppt打开ppt。但是我得到了例外。

 objApp =  new  Microsoft.Office.Interop.PowerPoint.Application { Visible = MsoTriState.msoTrue}; 
objPresSet = objApp.Presentations;
objPres = objPresSet.Open( c:\ myppts\ first.ppt );





但我得到以下异常:

COMException:PowerPoint无法打开使用以下代码

  private   void  btnPPT_Click( object  sender,EventArgs e)
{
Microsoft.Office.Interop.PowerPoint.Application pptApp = new Microsoft.Office.Interop.PowerPoint.Application();
Microsoft.Office.Core.MsoTriState ofalse = Microsoft.Office.Core.MsoTriState.msoFalse;
Microsoft.Office.Core.MsoTriState otrue = Microsoft.Office.Core.MsoTriState.msoTrue;
pptApp.Visible = otrue;
pptApp.Activate();
Microsoft.Office.Interop.PowerPoint.Presentations ps = pptApp.Presentations;
Microsoft.Office.Interop.PowerPoint.Presentation p = ps.Open( @ D:\ AQHA \ Wegbeschreibung \ Reithallenplan.pptx,ofalse,ofalse,otrue);
System.Diagnostics.Debug.Print(p.Windows.Count.ToString());
MessageBox.Show(pptApp.ActiveWindow.Caption);
}


I am trying to open ppt from "c:\myppts\first.ppt" with the below code. But i am getting the exception.

objApp = new Microsoft.Office.Interop.PowerPoint.Application { Visible = MsoTriState.msoTrue };
objPresSet = objApp.Presentations;
objPres = objPresSet.Open("c:\myppts\first.ppt");



But i am getting the below exception:
COMException: PowerPoint could not open the file.

解决方案

Try with following code

    private void btnPPT_Click(object sender, EventArgs e)
    {
      Microsoft.Office.Interop.PowerPoint.Application pptApp = new Microsoft.Office.Interop.PowerPoint.Application();
      Microsoft.Office.Core.MsoTriState ofalse = Microsoft.Office.Core.MsoTriState.msoFalse;
Microsoft.Office.Core.MsoTriState otrue = Microsoft.Office.Core.MsoTriState.msoTrue;
      pptApp.Visible = otrue;
      pptApp.Activate();
      Microsoft.Office.Interop.PowerPoint.Presentations ps = pptApp.Presentations;
      Microsoft.Office.Interop.PowerPoint.Presentation p = ps.Open(@"D:\AQHA\Wegbeschreibung\Reithallenplan.pptx", ofalse, ofalse, otrue);
      System.Diagnostics.Debug.Print(p.Windows.Count.ToString());
      MessageBox.Show(pptApp.ActiveWindow.Caption);
    }


这篇关于我想打开ppt的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆