((VBA)是否有一种方法可以使Powerpoint中的音频自动播放而没有.addeffect?

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

我正在写一些东西来从Access表中导出数据以生成PowerPoint演示文稿。到目前为止,所有功能都运行良好,但是添加音频后,无法自动播放。这是添加音频的代码段。

[我已经尝试了几个.AnimationSettings东西,也无法弄清楚如何格式化整个.Timeline.MainSequence.AddEffect代码。

我似乎无法使它正常工作。由于某种原因,无论何时我尝试使用“ ActivePresentation”“ ActiveWindow”,任何这些活动的东西,都给我一个错误。

Dim sAudio As String

sAudio = .Shapes(6).TextFrame.TextRange.Text

With .Shapes.AddMediaObject2(FileName:=sAudio, LinktoFile:=msoFalse, Savewithdocument:=msoCTrue, Left:=800, Top:=500)

End With

感谢您的帮助! :)

编辑:这是关于oShape变量的代码,上面写着“对象变量或未设置块变量”。

            Dim slideObj As Slide
            Dim oShape As Shape
            Dim oEffect As Effect

Set oShape = slideObj.Shapes.AddMediaObject2(FileName:=sAudio, LinktoFile:=False, Savewithdocument:=True, Left:=800, Top:=500)

Set oEffect = slideObj.TimeLine.MainSequence.AddEffect(oShape, msoAnimEffectMediaPlay, , msoAnimTriggerWithPrevious)
vba ms-access access-vba powerpoint
1个回答
0
投票

这里是将音频设置为自动播放的方法:

Sub AddAudio()
    Dim sAudio As String
    Dim oShape As Shape
    Dim oEffect As Effect

    sAudio = ActivePresentation.Slides(1).Shapes(2).TextFrame.TextRange.Text
    Set oShape = ActivePresentation.Slides(1).Shapes.AddMediaObject2(FileName:=sAudio, LinktoFile:=msoFalse, Savewithdocument:=msoCTrue, Left:=800, Top:=500)
    Set oEffect = ActivePresentation.Slides(1).TimeLine.MainSequence.AddEffect(oShape, msoAnimEffectMediaPlay, , msoAnimTriggerWithPrevious)
End Sub
© www.soinside.com 2019 - 2024. All rights reserved.