通过C#从PowerPoint幻灯片创建视频,抛出远程过程调用失败。 (Hresult的例外:0x800706BE)
我有一个 Windows 桌面 C# 应用程序,可以以编程方式将用户的 pptx 导出到 mp4。
我这里有代码:
try
{
Application application = new Microsoft.Office.Interop.PowerPoint.Application();
Presentation ppt = application.Presentations.Open("myppt.pptx", MsoTriState.msoFalse,
MsoTriState.msoFalse, MsoTriState.msoFalse);
ppt.CreateVideo("myppt.mp4");
}
catch (Exception ex)
{
logger.Error(ex.Message);
}
一切正常,并且使用 Powerpoint 2016 和旧版本 Office 365 powerpoint 成功创建了视频。 但是,在我将 Office 365 升级到最新版本 2203 (15028.20160) 后,CreateVideo() 总是失败并抛出异常:“远程过程调用失败”
System.Runtime.InteropServices.COMException (0x800706BE): 遠端程序呼叫失敗。 (發生例外狀況於 HRESULT: 0x800706BE)
於 Microsoft.Office.Interop.PowerPoint._Presentation.CreateVideo(String FileName, Boolean UseTimingsAndNarrations, Int32 DefaultSlideDuration, Int32 VertResolution, Int32 FramesPerSecond, Int32 Quality)
我也尝试过Presentation.SaveCopyAs(...) 和Presentation.Slides[x]。 Export(...) 和这些函数工作正常。
任何帮助将不胜感激。
更新:
如果将“WithWindow”参数设置为 true,则 CreateVideo() 可以工作 演示文稿 ppt = application.Presentations.Open("myppt.pptx", MsoTriState.msoFalse, MsoTriState.msoFalse, MsoTriState.msoTrue)
但我不知道原因...
I have a Windows desktop C# app which is to export user's pptx to mp4 programmatically.
I have code here:
try
{
Application application = new Microsoft.Office.Interop.PowerPoint.Application();
Presentation ppt = application.Presentations.Open("myppt.pptx", MsoTriState.msoFalse,
MsoTriState.msoFalse, MsoTriState.msoFalse);
ppt.CreateVideo("myppt.mp4");
}
catch (Exception ex)
{
logger.Error(ex.Message);
}
Everything works fine and video is created successfully with Powerpoint 2016 and older version Office 365 powerpoint.
However after I upgraded Office 365 to latest version 2203 (15028.20160), CreateVideo() always failed and throws exception: "The remote procedure call failed"
System.Runtime.InteropServices.COMException (0x800706BE): 遠端程序呼叫失敗。 (發生例外狀況於 HRESULT: 0x800706BE)
於 Microsoft.Office.Interop.PowerPoint._Presentation.CreateVideo(String FileName, Boolean UseTimingsAndNarrations, Int32 DefaultSlideDuration, Int32 VertResolution, Int32 FramesPerSecond, Int32 Quality)
I have also tried Presentation.SaveCopyAs(...) and Presentation.Slides[x].Export(...) and these functions work fine.
Any help would be appreciated.
Update:
CreateVideo() works if set "WithWindow" parameter to true in
Presentation ppt = application.Presentations.Open("myppt.pptx", MsoTriState.msoFalse, MsoTriState.msoFalse, MsoTriState.msoTrue)
But I don't know the reason...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用Office部署工具返回到先前的Office版本,在该版本中,您根据工作的长期行为。他们在第2203号版本中将其弄坏了,因此回到2202或更早的时间将修复它。
此
config.xml
文件工作:Use the Office Deployment Tool to roll back to a prior version of Office where the long-established behavior you're depending on worked. They broke it in release 2203, so rolling back to 2202 or earlier will fix it.
This
config.xml
file works:此异常通常表示您尝试从 Web 服务或 ASP.NET 应用程序自动化 PowerPoint。
Office 服务器端自动化的注意事项一文针对该场景指出了以下内容:
您可以考虑使用Open XML SDK如果您处理开放的 XML 文档或考虑使用为服务器端执行而设计的第三方组件。
This exception typically indicates that you trying to automate PowerPoint from a web service or ASP.NET application.
The Considerations for server-side Automation of Office article states the following for that scenario:
You may consider using the Open XML SDK if you deal with open XML documents or consider using third-party components designed for the server-side execution.
如果您的应用不依赖MS Office,那会更好。 aspose.spose.slides cloud sdk for .net 可以提供这样的要求。它不需要安装PowerPoint。该产品为演示处理提供了基于REST的API。这是一种付费产品,但是您可以每月拨打150个免费的API呼叫,以进行实验,学习和任何其他目的。
以下代码示例向您展示了如何使用aspose.net的云SDK将演示文稿转换为视频文件:
有时有必要将演示文稿转换为没有任何代码的视频。对于这种情况,您可以使用免费 powerpoint到视频转换器。
我在Aspose担任支持开发人员。
It would be better if your app did not depend on MS Office. Aspose.Slides Cloud SDK for .NET can provide such a requirement. It does not require PowerPoint installed. This product provides a REST-based API for presentation processing. It is a paid product, but you can make 150 free API calls per month for experimentation, learning, and any other purpose.
The following code example shows you how to convert a presentation to a video file using Aspose.Slides Cloud SDK for .NET:
Sometimes it is necessary to convert presentations to videos without any code. For such cases, you can use a free PowerPoint to Video Converter.
I work as a Support Developer at Aspose.