如何在Powerpoint VBA中编写此代码? “将幻灯片上的视频文件设置为在幻灯片放映模式下自动开始。”

时间:2019-08-27 05:32:03

标签: vba powerpoint

我经常使用MS PPT,文件中嵌入了许多视频。我想运行一个宏,以将所选幻灯片中的视频设置为在开始时自动播放。

Sub SetStartAutomatically()
    Dim mySld As Slide
    Dim myVid As Shape
    Dim sldX As Integer

    sldX = ActiveWindow.View.Slide.SlideIndex
    Set mySld = ActivePresentation.Slides(sldX)
    Set myVid = mySld.Shapes(1)

    myVid.AnimationSettings.PlaySettings.PlayOnEntry = msoTrue
End Sub

我尝试了上面的代码,但是没有用。

Start was set on On Click

1 个答案:

答案 0 :(得分:0)

尝试此操作作为最后一行:

mySld.TimeLine.MainSequence.AddEffect myVid, msoAnimEffectMediaPlay, , msoAnimTriggerWithPrevious