【问题标题】:In Powerpoint VBA, how do I make an embedded video start playing?在 Powerpoint VBA 中,如何让嵌入的视频开始播放?
【发布时间】:2021-05-21 11:38:12
【问题描述】:

我的 Office 365 PowerPoint 演示文稿只有一张幻灯片。该幻灯片包含一个带有嵌入(未链接,非 OLE)视频的形状,该视频最初是从 .mp4 文件插入的。当我点击它时视频开始播放,但我需要从 VBA 代码控制它。我没有尝试过(见下文),当然我没有收到任何错误消息或任何反馈。如何从代码开始(和停止)视频?

Sub PlayVideo(Name)
Set Shape = GetShape(Name)
' Shape.MediaType == ppMediaTypeMovie

With Shape.AnimationSettings
    .Animate = msoTrue
    .AdvanceMode = ppAdvanceOnTime
    .AdvanceTime = 0
    .TextLevelEffect = ppAnimateByAllLevels
    With .PlaySettings
        .PlayOnEntry = msoTrue
        .PauseAnimation = msoFalse
        .LoopUntilStopped = msoTrue
    End With
End With
With Slide.TimeLine.MainSequence
    Set AnimationEffect = .AddEffect(Shape:=Shape, effectid:=msoAnimEffectMediaPlay)
    With AnimationEffect
        Set Behaviour = .Behaviors.Add(msoAnimTypeCommand)
        With Behaviour
            .CommandEffect.Type = msoAnimCommandTypeVerb
            .CommandEffect.Command = "play"
        End With
    End With
End With
End Sub

【问题讨论】:

  • includes a shape with embedded (not linked, not OLE) video 视频是如何嵌入的?
  • @SiddharthRout 我这样嵌入视频:工具栏 > 插入选项卡 > 视频 > 此设备 > [...\algorithm panel.mp4]

标签: vba video powerpoint


【解决方案1】:

要开始视频使用

SlideShowWindows(1).View.Player("algorithm panel").Play

停止视频使用

SlideShowWindows(1).View.Player("algorithm panel").Stop

这是一个例子。将其粘贴到模块中。我的视频名称是SAMPLE.mp4

Option Explicit

Sub StartVideo()
    SlideShowWindows(1).View.Player("SAMPLE").Play
End Sub

Sub StopVideo()
    SlideShowWindows(1).View.Player("SAMPLE").Stop
End Sub

接下来在幻灯片中插入 2 个操作按钮并分配宏

我们完成了。

【讨论】:

    猜你喜欢
    • 2011-07-18
    • 2016-09-30
    • 2017-09-19
    • 2018-03-16
    • 2017-05-07
    • 1970-01-01
    • 2013-04-24
    • 2012-03-19
    • 1970-01-01
    相关资源
    最近更新 更多