如何在PowerPoint中使用宏自动播放所有音频文件?

问题描述 投票:0回答:1

我有几个 PowerPoint 演示文稿中的音频文件。我希望它们全部自动播放(而不是通过点击)。有没有可能用vba宏来做到这一点? 此代码运行,但没有任何变化:

Sub SetAudioToPlayAutomatically()
    Dim sld As slide
    Dim shp As shape
    
    For Each sld In ActivePresentation.Slides
        For Each shp In sld.Shapes
            If shp.Type = msoMedia Then
                If shp.MediaType = ppMediaAudio Then
                    Set oEffect = sld.TimeLine.MainSequence.AddEffect(shp, msoAnimEffectMediaPlay, , msoAnimTriggerWithPrevious)
                    oEffect.MoveTo 1
                End If
            End If
        Next shp
    Next sld
    
    MsgBox "All audiofiles set to automatic play.", vbInformation
End Sub

我也尝试了

shp.AnimationSettings.PlaySettings.StartingEffect = ppAnimationStartAutomatically
,但是出现了编译错误——未知值
ppAnimationStartAutomatically
。预先感谢!

vba powerpoint presentation
1个回答
0
投票

尝试将

ppMediaAudio
替换为
ppMediaTypeSound

请参阅此 Microsoft 文档

Shape.MediaType 属性 (PowerPoint)

© www.soinside.com 2019 - 2024. All rights reserved.