ird*_*ird 6 c# video powerpoint
某些Powerpoint演示文稿包含嵌入式电影.如何使用C#(VSTO或Oficce COM Api)从演示文稿中导出电影(或获取电影文件的路径)?
这是一个简单的演示:
不要忘记添加对PowerPoint COM API(Microsoft PowerPoint 12.0对象库)的引用.
using PowerPoint = Microsoft.Office.Interop.PowerPoint;
using Office = Microsoft.Office.Core;
Run Code Online (Sandbox Code Playgroud)
那么你可以像这样获得电影之路
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
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
我希望这将有所帮助.
[编辑:]
关于史蒂夫的评论,如果你只想要嵌入式电影,你只需像任何其他zip文件一样解压缩.pptx文件(例如使用DotNetZip)并在此路径中查找嵌入的视频([PowerPoint_fileName]\ppt\media)