Click here to Skip to main content
15,888,610 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
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?
Posted
Updated 13-May-16 8:40am
v2

C#
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();
 
Share this answer
 
Comments
Joezer BH 10-Sep-13 3:34am    
5ed!
When it(Presentations.Open) opens large files(>= 1G ppt file), it loads very slowly, and how to deal with it ?
 
Share this answer
 
Are you trying to do this:

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


Thanks,
Ambesha
 
Share this answer
 
Comments
CHill60 2-Aug-13 12:53pm    
nope - he was using interop ... a year ago. Chetan Ghorely's solution works
Ambesha 3-Aug-13 3:22am    
Question is why if he just want to open pptx file.
CHill60 4-Aug-13 13:25pm    
He may have wanted to do more ... such as automatically display the slideshow or highlight a particular slide or link the presentation to some audio etc etc etc. The main point though is that the question was resolved over a year ago

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900