Some Powerpoint presentation contains embedded movies. How to export movies from presentation (or get path to movie file) using C# (VSTO or Oficce COM Api)?
On the File menu, select Save to ensure all your recent work has been saved in PowerPoint presentation format (. pptx). Click File > Export > Create a Video. (Or, on the Recording tab of the ribbon, click Export to Video.)
Here is simple demo to do this:
don't forget to add reference to the PowerPoint COM API (Microsoft PowerPoint 12.0 Object Library).
using PowerPoint = Microsoft.Office.Interop.PowerPoint;
using Office = Microsoft.Office.Core;
then you can get the movies 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
}
}
}
}
I hope this will help.
[Edit:]
regarding Steve comment if you want just the embedded movies, you need just to unpack the .pptx file like any other zip file (e.g. using DotNetZip) and look for embedded videos in this path ([PowerPoint_fileName]\ppt\media)
It is very easy. Extract the file as Zip file using SharpZipLib library, the files will be at ppt\media folder :)
this question will help you:
Programmatically extract embedded file from PowerPoint presentation
And this is the link of sharp-zip-lib:
http://www.icsharpcode.net/opensource/sharpziplib/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With