通过VBA将音频剪辑添加到跨多个幻灯片的PowerPoint演示文稿

时间:2011-08-08 18:07:13

标签: vba powerpoint powerpoint-vba

要在演示文稿中的多张幻灯片中播放作为形状插入的音频剪辑,可在效果标签中的播放声音对话框中选择一个名为的选项停止播放,可以设置为 __幻灯片

我浏览了对象模型,甚至尝试使用ppt 2003录制宏(该选项不记录)。如何(如果可以)可以通过 VBA 设置此选项?

Stop Playing After __ slides option

我正在添加声音的方式(在幻灯片提升后停止)是:

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 个答案:

答案 0 :(得分:2)

请改为尝试:

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