PowerPoint VBA Spin Animation with Audio

Поделиться
HTML-код
  • Опубликовано: 8 янв 2025
  • 'PowerPoint VBA Spin Animation with Audio
    Sub AddSpinAnimation()
    Dim Myslide As slide
    Dim Myshape As shape
    Dim Myeffect As effect
    Dim soundShape As shape
    Dim Soundfile As String
    Soundfile = "C:\Users\Admin\Music\Sound Affects\steampunk.wav"
    ' Set the target slide (Slide 1)
    Set Myslide = ActivePresentation.Slides(1)
    ' Set the target shape
    Set Myshape = Myslide.Shapes("T3")
    ' Add a spin animation effect to the shape with an On Click trigger
    Set Myeffect = Myslide.TimeLine.MainSequence.AddEffect(shape:=Myshape, _
    effectId:=msoAnimEffectAppear, _
    trigger:=msoAnimTriggerOnClick)
    ' Add sound file to effect
    Myshape.AnimationSettings.SoundEffect.ImportFromFile (Soundfile)
    ' change animation to Spin effect as workaround since soundeffect cannot be added to spin animation object on the first Instance
    Myslide.TimeLine.MainSequence.Item(1).EffectType = msoAnimEffectSpin
    ' Set spin rotation to 15 degrees.
    Myslide.TimeLine.MainSequence.Item(1).EffectParameters.Amount = 15
    ' Set Duration to 0.2
    Myslide.TimeLine.MainSequence.Item(1).Timing.Duration = 0.2
    End Sub

Комментарии •