reading powerpoint presentations with c#

Shurikn

Regular
Joined
Jul 14, 2004
is there any way to read powerpoint presentation from c#. I dont want powerpoint to open, i want to play the things directly from my program.
 

pelican

Newcomer
Joined
Feb 22, 2005
which powerpoint version are you using?

if you are using office xp and above, powerpoint should not open.
 

Shurikn

Regular
Joined
Jul 14, 2004
I got powerPoint 2003, and it'S openning, maybe you're using something else than I do.

Code:
String strTemplate, strPic;
			strTemplate =
				"C:\\Documents and Settings\\Nicolas Dufour\\Bureau\\TUJYDKJ.pps";
			strPic = "C:\\Documents and Settings\\Nicolas Dufour\\Mes documents\\Mes images\\200162757-001.jpg";
			bool bAssistantOn;

			PowerPoint.Application objApp;
			PowerPoint.Presentations objPresSet;
			PowerPoint._Presentation objPres;
			PowerPoint.Slides objSlides;
			PowerPoint._Slide objSlide;
			PowerPoint.TextRange objTextRng;
			PowerPoint.Shapes objShapes;
			PowerPoint.Shape objShape;
			PowerPoint.SlideShowWindows objSSWs;
			PowerPoint.SlideShowTransition objSST;
			PowerPoint.SlideShowSettings objSSS;
			PowerPoint.SlideRange objSldRng;
			Graph.Chart objChart;

			//Create a new presentation based on a template.
			objApp = new PowerPoint.Application();
			objApp.Visible = MsoTriState.msoTrue;
			objPresSet = objApp.Presentations;
			objPres = objPresSet.Open(strTemplate,
				MsoTriState.msoFalse, MsoTriState.msoTrue, MsoTriState.msoTrue);
			objSlides = objPres.Slides;
...
...
...
	//Prevent Office Assistant from displaying alert messages:
			bAssistantOn = objApp.Assistant.On;
			objApp.Assistant.On = false;
...
...
...
			//Wait for the slide show to end.
			objSSWs = objApp.SlideShowWindows;
			while(objSSWs.Count>=1)
			{
					System.Threading.Thread.Sleep(100);
			}
			//Reenable Office Assisant, if it was on:
			if(bAssistantOn)
			{
				objApp.Assistant.On = true;
				objApp.Assistant.Visible = false;
			}

			//Close the presentation without saving changes and quit PowerPoint.
			objPres.Close();
			objApp.Quit();

and the program always fail on the objApp.Quit() giving that error:

An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in ZoneMedia.exe

Additional information: Presentation (unknown member) : Object does not exist.

and the powerPoint window stays open.
 

keenlearner

Newcomer
Joined
Apr 29, 2009
declare a PresentationClose event handler of the PowerPoint Application class before objApp.Quit();
and close the presentation in the method definition.
also remove objPres.close();
you wont get this error anymore...
 

Cindy Meister

Newcomer
Joined
Apr 15, 2009
is there any way to read powerpoint presentation from c#. I dont want powerpoint to open, i want to play the things directly from my program.
I got powerPoint 2003, and it'S openning

If you don't want PowerPoint to run at all, then you'd have to read the closed file. For version 2003 (and earlier) that means the old, proprietary binary file formats. The following links are to a forum where these are discussed, and to information on obtaining the specs.

- Forum
- obtaining

For Office 2007 you'd need to use the Office 2007 OpenXML file formats (just in case you'd need to migrate your solution in the future).
 
Top Bottom