首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Powerpoint互操作

Powerpoint互操作
EN

Stack Overflow用户
提问于 2012-11-15 14:30:36
回答 1查看 943关注 0票数 3

我刚开始接触.NET,我想制作一个控制台应用程序,将一个.pptx文件转换成一个.‘ll。我使用powerpoint interop.But成功地做到了这一点,如果我构建应用程序并将它传输到另一台计算机,我会得到一个异常错误,HRESULT E_FAIL已经为COM对象返回了一个异常错误(我在两台pc上都有powerpoint ),我运行它的原因是,我写了它--I everything works alright.But,而不是为第一个time.Meaning --当我启动我的pc并运行它时,我会得到相同的异常。第二次尝试运行它时,运行properly.What可能是问题所在?我猜是互操作和powerpoint的一些东西,但我无法解决它。

好的,这是代码:

代码语言:javascript
复制
using Microsoft.Office.Core;
using Microsoft.Office.Interop.PowerPoint;
using PowerPoint = Microsoft.Office.Interop.PowerPoint;
using System.Runtime.InteropServices;
using System.IO;
using System;

  namespace Microsoft.Office.Interop.PowerPoint
 {
  class Program
  {

    static void Main(string[] args)
    {

        string fileName = args[0];
        string exportName = args[1];
        string exportPath = args[2];

        Microsoft.Office.Interop.PowerPoint.Application ppApp = new Microsoft.Office.Interop.PowerPoint.Application();
        ppApp.Visible = MsoTriState.msoTrue;
        ppApp.WindowState = PpWindowState.ppWindowMinimized;
        Microsoft.Office.Interop.PowerPoint.Presentations oPresSet = ppApp.Presentations;
        Microsoft.Office.Interop.PowerPoint._Presentation oPres = oPresSet.Open(fileName,
                    MsoTriState.msoFalse, MsoTriState.msoFalse,
                    MsoTriState.msoFalse);
        try
        {
            oPres.CreateVideo(exportName);
            oPres.SaveCopyAs(String.Format(exportPath, exportName),
                PowerPoint.PpSaveAsFileType.ppSaveAsWMV,
                MsoTriState.msoCTrue);
        }
        finally
        {
            ppApp.Quit();
        }
    }

}
}
EN

回答 1

Stack Overflow用户

发布于 2016-01-05 21:20:59

_Presentation.CreateVideo不会用powerpoint创建视频。它在powerpoint中创建一个视频。无论如何,这就是文件上说

尝试Presentation.SaveAs,然后对文件类型使用PpSaveAsFileType.ppSaveAsWMV

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13399604

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档