Jump to content
Xtreme .Net Talk

Recommended Posts

Posted
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.
Posted

I got powerPoint 2003, and it'S openning, maybe you're using something else than I do.

 

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.

  • 3 years later...
Posted

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...

Posted
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).

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...