我刚开始接触.NET,我想制作一个控制台应用程序,将一个.pptx文件转换成一个.‘ll。我使用powerpoint interop.But成功地做到了这一点,如果我构建应用程序并将它传输到另一台计算机,我会得到一个异常错误,HRESULT E_FAIL已经为COM对象返回了一个异常错误(我在两台pc上都有powerpoint ),我运行它的原因是,我写了它--I everything works alright.But,而不是为第一个time.Meaning --当我启动我的pc并运行它时,我会得到相同的异常。第二次尝试运行它时,运行properly.What可能是问题所在?我猜是互操作和powerpoint的一些东西,但我无法解决它。
好的,这是代码:
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();
}
}
}
}发布于 2016-01-05 21:20:59
_Presentation.CreateVideo不会用powerpoint创建视频。它在powerpoint中创建一个视频。无论如何,这就是文件上说。
尝试Presentation.SaveAs,然后对文件类型使用PpSaveAsFileType.ppSaveAsWMV。
https://stackoverflow.com/questions/13399604
复制相似问题