在Powerpoint中插入并自动播放音频文件?

时间:2019-01-15 16:02:52

标签: vba audio office365 ms-office powerpoint

我有以下代码(提供给Shyam Pillai):

Sub SampleTest()
Call InsertAudio("G:\Music\track1.mp3", ActivePresentation.Slides(1))
Call InsertAudio("G:\Music\track2.mp3", ActivePresentation.Slides(2))

End Sub

Sub InsertAudio(Track As String, oSlide As Slide)
Dim oShp As Shape
Dim oEffect As Effect

'Add the audio shape
Set oShp = oSlide.Shapes.AddMediaObject2(Track, True, False, 10, 10)

'Set audio to play automatically
Set oEffect = oSlide.TimeLine.MainSequence.AddEffect(oShp, msoAnimEffectMediaPlay, , msoAnimTriggerWithPrevious)
oEffect.MoveTo 1

'Hide during slide show
With oEffect
    .EffectInformation.PlaySettings.HideWhileNotPlaying = True
End With

End Sub

该代码有效,但是我想知道可以添加些什么,因此当我运行代码时,它会打开一个对话框,从中可以插入文件中的音频列表,然后依次插入幻灯片滑动代码中的设置(自动,在显示过程中隐藏)。

预先感谢您的帮助

0 个答案:

没有答案