C# 用C语言将电影从Powerpoint导出到文件#
某些Powerpoint演示文稿包含嵌入式电影。C# 用C语言将电影从Powerpoint导出到文件#,c#,video,powerpoint,C#,Video,Powerpoint,某些Powerpoint演示文稿包含嵌入式电影。 如何使用C#(VSTO或Oficce COM Api)从演示文稿导出电影(或获取电影文件的路径) 签出以下链接 下面是一个简单的演示: 别忘了添加对PowerPoint COM API的引用 (Microsoft PowerPoint 12.0对象库)。 然后你可以得到这样的电影路径 private void button1_Click(object sender, EventArgs e) { PowerPoi
如何使用C#(VSTO或Oficce COM Api)从演示文稿导出电影(或获取电影文件的路径) 签出以下链接
下面是一个简单的演示: 别忘了添加对PowerPoint COM API的引用 (Microsoft PowerPoint 12.0对象库)。 然后你可以得到这样的电影路径
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
}
}
}
}
我希望这会有所帮助
[编辑:
关于Steve comment,如果您只想要嵌入的电影,只需像任何其他zip文件一样解压缩.pptx文件(例如,使用DotNetZip),并在此路径中查找嵌入的视频([PowerPoint\u fileName]\ppt\media)这非常简单。使用SharpZipLib库将文件解压缩为Zip文件,文件将位于ppt\media文件夹:) 这个问题将帮助您: 这是夏普zip库的链接:
不幸的是,它不会。最初的问题规定视频是嵌入的。此示例将提供链接(但不是嵌入)视频的路径。我想他在这个问题中指的是链接视频,因为获取嵌入视频更容易,而且不需要office COM api,只需像任何其他zip文件一样解压缩.pptx文件(例如使用DotNetZip),然后在此路径中查找嵌入视频([PowerPointfileName]\ppt\media)是的;我在对原始帖子的评论中提到了解压技巧,但您做得更好,并提供了zip中的实际路径。谢谢因为电影是嵌入的,所以没有通往它们的路径。它们是PPTX文件本身的一部分。您可以通过解压缩PPTX中的嵌入式媒体(电影和声音)。深入到解压文件的文件夹结构中,就会有一个媒体文件夹。声音/视频将在其中。但是,它们不会有原始文件名。取而代之的是它们的名称,如Media1.mov等。在第一个示例中,断开了链接
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
}
}
}
}