reading powerpoint presentations with c#

Shurikn

Well-known member
Joined
Jul 14, 2004
Messages
60
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.
 
which powerpoint version are you using?

if you are using office xp and above, powerpoint should not open.
 
I got powerPoint 2003, and itS openning, maybe youre 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.
 
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...
 
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 itS openning

If you dont want PowerPoint to run at all, then youd 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 youd need to use the Office 2007 OpenXML file formats (just in case youd need to migrate your solution in the future).
 
Back
Top