使用C#在PowerPoint演示文稿中自动播放电影 [英] Autoplaying a movie in a PowerPoint presentation with C#

查看:289
本文介绍了使用C#在PowerPoint演示文稿中自动播放电影的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在尝试通过C#和Microsoft.Office.Interop.PowerPoint更改.pptx文件中的某些设置.我在演示文稿的几张幻灯片上链接了一些.wmv电影.在创建演示文稿时,所有电影均会在单击后立即播放.但是,我想将其更改为在查看幻灯片后自动开始播放.许多演示文稿都必须执行此操作,因此无法手动执行此操作.

I am currently trying to change some settings in a .pptx files via C# and Microsoft.Office.Interop.PowerPoint. I have some .wmv movies linked on several slides of the presentation. At the time the presentations were created, all movies play as soon as they are clicked. However, I want to change this to start automatically playing as soon as the slide is viewed. This this has to be done to a lot of presentations, so there is no way to do this manually.

我找到了PlaySettings.PlayOnEntry属性,但是我不知道如何使用它.我找到了几个示例,说明如何嵌入要嵌入的新影片(然后,仅适用于Visual Basic),但是由于已经嵌入了影片,所以这不是我想要的.

I found the PlaySettings.PlayOnEntry property, but I can't figure out how to use it. I found several examples how to do this with a new movie to be embedded (and then, only for Visual Basic), but since the movies are already embedded, this is not what I want.

我也不知道如何实际访问当前幻灯片上的任何对象,也许有一种方法可以检查形状是否为视频文件,然后更改上述设置,但是MSDN参考不是很有帮助关于Office主题.如果需要的话,我正在使用Powerpoint 2007和Visual Studio 2010.

I also have no idea how I can actually access any objects on the current slide, maybe there is a way to check if a shape is a video-file and then change above setting, but the MSDN-Reference is not very helpful on Office-Topics. I'm using Powerpoint 2007 and Visual Studio 2010 if that matters.

推荐答案

知道了.在演示文稿的所有形状中进行搜索并过滤出电影的效果如下:

Got it. Searching through all shapes of the Presentation and filtering out the movies works:

//While iterating through all slides i:
   objShapes = objPres.Slides[i].Shapes;
    foreach (Microsoft.Office.Interop.PowerPoint.Shape s in objShapes) {
            if(s.Name.Contains(".wmv")){
            s.AnimationSettings.PlaySettings.PlayOnEntry = MsoTriState.msoTrue;
    }
   }

这篇关于使用C#在PowerPoint演示文稿中自动播放电影的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆