Export movies from Powerpoint to file in C #

The PowerPoint presentation contains embedded videos. How to export movies from a presentation (or get the path to a movie file) using C # (VSTO or Oficce COM Api)?

+6
c # video powerpoint
source share
3 answers

Here is a simple demo for this:

do not forget to add a link to the PowerPoint COM API (Microsoft PowerPoint Object Library 12.0).

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

then you can get a movie path like this

  private void button1_Click(object sender, EventArgs e) { PowerPoint.Application app = new PowerPoint.Application(); app.Visible = Office.MsoTriState.msoTrue; //open powerpoint file in your hard drive app.Presentations.Open(@"e:\my tests\hello world.pptx"); foreach (PowerPoint.Slide slide in app.ActivePresentation.Slides) { PowerPoint.Shapes slideShapes = slide.Shapes; foreach (PowerPoint.Shape shape in slideShapes) { if (shape.Type == Office.MsoShapeType.msoMedia && shape.MediaType == PowerPoint.PpMediaType.ppMediaTypeMovie) { //LinkFormat.SourceFullName contains the movie path //get the path like this listBox1.Items.Add(shape.LinkFormat.SourceFullName); //or use System.IO.File.Copy(shape.LinkFormat.SourceFullName, SOME_DESTINATION) to export them } } } } 

Hope this helps.

[Edit:]

regarding Steve's comment, if you want only embedded movies, you just need to unzip the .pptx file, like any other zip file (for example, using DotNetZip), and look for embedded videos along this way ([PowerPoint_fileName] \ ppt \ media)

+5
source share

It is very easy. Extract the file as a Zip file using the SharpZipLib library, the files will be in the ppt \ media folder :)

this question will help you:

Programmatically extract embedded file from PowerPoint presentation

And this is the sharp-zip-lib link:

http://www.icsharpcode.net/opensource/sharpziplib/

+3
source share
+1
source share

All Articles