【发布时间】:2020-07-13 20:42:14
【问题描述】:
我想使用 PowerPoint VBA (Microsoft 365 MSO) 向 PowerPoint 幻灯片添加两个声音形状,均在点击时触发。
幻灯片时间线将是:
- 第一次点击开始播放声音
- 第二次点击停止第一个声音并开始第二个声音。
我能够放置声音形状并添加动画对象来触发声音。
代码将添加一张新幻灯片,创建两个声音形状并让它们在点击时触发,但声音 1 不会停止播放。
Sub TestSoundTrigger()
Dim slTestSoundSlide As Slide
Dim shSoundShape1 As Shape
Dim shSoundShape2 As Shape
Dim efSoundShape1 As Effect
Dim efSoundShape2 As Effect
' Create the slide
Set slTestSoundSlide = ActivePresentation.Slides.AddSlide(ActivePresentation.Slides.Count + 1, ActivePresentation.Designs(1).SlideMaster.CustomLayouts(1))
' Add 2 sound shapes
Set shSoundShape1 = slTestSoundSlide.Shapes.AddMediaObject2(ActivePresentation.Path & "\testsound1.mp3", True, False, 10, 10)
Set shSoundShape2 = slTestSoundSlide.Shapes.AddMediaObject2(ActivePresentation.Path & "\testsound2.mp3", True, False, 10, 10)
' Add the 2 triggers to play the sounds on click in turn
Set efSoundShape1 = slTestSoundSlide.TimeLine.MainSequence.AddEffect(shSoundShape1, effectId:=msoAnimEffectMediaPlay)
Set efSoundShape2 = slTestSoundSlide.TimeLine.MainSequence.AddEffect(shSoundShape2, effectId:=msoAnimEffectMediaPlay)
End Sub
我检查了 Effect 和 Timeline 对象的属性,但找不到这个。
【问题讨论】:
标签: vba powerpoint