如何使用C#应用程序打开Powerpoint PPTX文件? [英] How can I open Powerpoint PPTX File with C# application?

查看:1096
本文介绍了如何使用C#应用程序打开Powerpoint PPTX文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 使用 Microsoft.Office.Core; 
使用 PowerPoint = Microsoft.Office.Interop.PowerPoint;

PowerPoint.Application oPPT;
PowerPoint.Presentations objPPTSHOW;
PowerPoint.Presentation objSHOW;
oPPT = new PowerPoint.ApplicationClass();
oPPT.Visible = Microsoft.Office.Core.MsoTriState.msoCTrue;
objPPTSHOW = oPPT.Presentations;
objSHOW = objPPTSHOW.Open(txtFILELOC.Text,MsoTriState.msoFalse,MsoTriState.msoCTrue,MsoTriState.msoCTrue);







我使用这个编码来打开PPT文件,但它不起作用。我正在使用C#2005并选择了MicroSoft PowerPoint 12.0对象库。

错误显示COMException未处理。错误代码是-2147467259。有人可以帮我吗?

解决方案

 Microsoft.Office.Interop.PowerPoint.Application ppApp =  new  Microsoft.Office.Interop.PowerPoint.Application(); 
ppApp.Visible = MsoTriState.msoTrue;
演示文稿ppPresens = ppApp.Presentations;演示文稿objPres = ppPresens.Open(e.FullPath,MsoTriState.msoFalse,MsoTriState.msoTrue,MsoTriState.msoTrue);
幻灯片objSlides = objPres.Slides;
Microsoft.Office.Interop.PowerPoint.SlideShowWindows objSSWs; Microsoft.Office.Interop.PowerPoint.SlideShowSettings objSSS;
// 运行幻灯片放映
objSSS = objPres.SlideShowSettings;
objSSS.Run();
objSSWs = ppApp.SlideShowWindows;
while (objSSWs.Count > = 1
System.Threading.Thread.Sleep( 100 );
// 关闭演示文稿而不保存更改并退出PowerPoint
objPres.Close ();
ppApp.Quit();


当它(Presentations.Open)打开大文件(> = 1G ppt文件)时,它加载非常慢慢地,以及如何处理它?<​​/ blockquote>

你是否想要这样做:



System.Diagnostics。 Process.Start(pptfilename.pptx)





谢谢,

Ambesha


using Microsoft.Office.Core;
using PowerPoint = Microsoft.Office.Interop.PowerPoint;

         PowerPoint.Application oPPT;
         PowerPoint.Presentations objPPTSHOW;
         PowerPoint.Presentation objSHOW;
         oPPT = new PowerPoint.ApplicationClass();
         oPPT.Visible = Microsoft.Office.Core.MsoTriState.msoCTrue;
         objPPTSHOW = oPPT.Presentations;
         objSHOW = objPPTSHOW.Open(txtFILELOC.Text, MsoTriState.msoFalse, MsoTriState.msoCTrue, MsoTriState.msoCTrue);




I use this coding for opening PPT File but it doesn't work. I'm using C# 2005 and selected MicroSoft PowerPoint 12.0 Object library.
error show COMException was unhandled. Error code is -2147467259. Anyone can help me please?

解决方案

Microsoft.Office.Interop.PowerPoint.Application ppApp = new Microsoft.Office.Interop.PowerPoint.Application();
ppApp.Visible = MsoTriState.msoTrue;
Presentations ppPresens = ppApp.Presentations;							Presentation objPres = ppPresens.Open(e.FullPath, MsoTriState.msoFalse, MsoTriState.msoTrue, MsoTriState.msoTrue);
Slides objSlides = objPres.Slides;
								Microsoft.Office.Interop.PowerPoint.SlideShowWindows objSSWs;							Microsoft.Office.Interop.PowerPoint.SlideShowSettings objSSS;
//Run the Slide show
objSSS = objPres.SlideShowSettings;
objSSS.Run();
objSSWs = ppApp.SlideShowWindows;
while(objSSWs.Count >= 1) 
System.Threading.Thread.Sleep(100);
//Close the presentation without saving changes and quit PowerPoint
objPres.Close();
ppApp.Quit();


When it(Presentations.Open) opens large files(>= 1G ppt file), it loads very slowly, and how to deal with it ?


Are you trying to do this:

System.Diagnostics.Process.Start("pptfilename.pptx")


Thanks,
Ambesha


这篇关于如何使用C#应用程序打开Powerpoint PPTX文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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