Add audio clip via VBA to PowerPoint Presentation that spans multiple slides

ⅰ亾dé卋堺 提交于 2020-05-27 06:47:27

问题


To play an audio clip inserted as a shape across multiple slides in a presentation, there is an option in the Play Sound dialog in the Effect tab called Stop playing and this can be set to After __ slides.

I've browsed the object model and even attempted recording a macro using ppt 2003 (the option does not record). How (if it can) can this option be set via VBA?

Stop Playing After __ slides option

The way I'm currently adding a sound (that stops after the slides are advanced) is:

Dim oSlide As Slide
Dim oShp As Shape
Dim oEffect As Effect

Set oSlide = ActivePresentation.Slides(2)

Set oShp = oSlide.Shapes.AddMediaObject("C:\MyAudioClip.wav", True, False, 10, 10)

Set oEffect = oSlide.TimeLine.MainSequence.AddEffect(oShp, msoAnimEffectMediaPlay, , msoAnimTriggerWithPrevious)
oEffect.MoveTo 1

回答1:


Try this instead:

Dim oSlide As Slide
Dim oShp As Shape
Dim oEffect As Effect

Set oSlide = ActivePresentation.Slides(1)

Set oShp = oSlide.Shapes.AddMediaObject("p:\testfile\media\minivincent.wav", True, False, 10, 10)

With oShp.AnimationSettings.PlaySettings
    .PlayOnEntry = True
    .PauseAnimation = False
    .StopAfterSlides = 19
End With


来源:https://stackoverflow.com/questions/6986507/add-audio-clip-via-vba-to-powerpoint-presentation-that-spans-multiple-slides

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!