Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/286.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Office.Interop.Powerpoint导入_C#_Interop_Powerpoint - Fatal编程技术网

C# Office.Interop.Powerpoint导入

C# Office.Interop.Powerpoint导入,c#,interop,powerpoint,C#,Interop,Powerpoint,我无法将PowerPoint转换为HTML 这是代码 Microsoft.Office.Interop.PowerPoint.Application oApplication = new Microsoft.Office.Interop.PowerPoint.Application(); Microsoft.Office.Interop.PowerPoint.Presentation oPresentation = oApplication.Presentations.Open(sourceFi

我无法将PowerPoint转换为HTML

这是代码

Microsoft.Office.Interop.PowerPoint.Application oApplication = new Microsoft.Office.Interop.PowerPoint.Application();
Microsoft.Office.Interop.PowerPoint.Presentation oPresentation = oApplication.Presentations.Open(sourceFileName);
oPresentation.SaveAs(destFileName, Microsoft.Office.Interop.PowerPoint.PpSaveAsFileType.ppSaveAsHTML);
oPresentation.Close();
oApplication.Quit();
我得到以下错误

System.Runtime.InteropServices.COMException(0x80048240): 演示文稿(未知成员):请求无效。PowerPoint框架 窗口不存在。在 Microsoft.Office.Interop.PowerPoint.Presentations.Open(字符串) 文件名,MsoTriState只读,MsoTriState无标题,MsoTriState (带窗)在 SmartBoard_V2.Section.Admin.Areas.DersEditor.DersEdit.convertPowerPoint(字符串 fennKod)在c:\Users\Kamandar\Documents\Visual Studio中 2012\Projects\SmartBoard\u V2\SmartBoard\u V2\Section\Admin\Areas\DersEditor\DersEdit.aspx.cs:第163行


我怀疑您需要在尝试保存应用程序之前将其设置为可见

为此,只需在声明
oPresentation
对象之前添加以下代码即可

oApplication .Visible = Office.MsoTriState.msoTrue;

编辑:刚刚注意到您正在使用ASP.NET,尽管不推荐使用,但您可以检查是否存在类似问题。

请注意,如果您正在自动执行PPT 2013(或可能更高版本),则此操作将不起作用。从2013年起,PowerPoint不再具有SaveAsHTML方法

您不应在ASP.NET页面中使用Office。这是已知的问题来源。您不能在ASP.NET中使用。w3wp不是用户交互的。阿没有看到他正在使用ASP.NET,否则这将解决问题。