使用 C# 在 PowerPoint 演示文稿中自动播放电影

发布于 2024-10-07 01:22:52 字数 429 浏览 0 评论 0原文

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

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

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

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.

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.

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

英雄似剑 2024-10-14 01:22:52

@Lennart 的解决方案是其中的一部分,然后您需要一个页面触发器

var videoAnimation = slide.TimeLine.MainSequence.FindFirstAnimationFor(objShapes);
if (videoAnimation != null)
{
    videoAnimation.Timing.TriggerType = PowerPoint.MsoAnimTriggerType.msoAnimTriggerWithPrevious;
}

@Lennart's solution is part of it, you then need a page trigger

var videoAnimation = slide.TimeLine.MainSequence.FindFirstAnimationFor(objShapes);
if (videoAnimation != null)
{
    videoAnimation.Timing.TriggerType = PowerPoint.MsoAnimTriggerType.msoAnimTriggerWithPrevious;
}
情感失落者 2024-10-14 01:22:52

知道了。搜索所有形状的演示文稿并过滤出电影作品:

//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;
    }
   }

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;
    }
   }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文