Tarounen
Tarounen

Reputation: 1159

Programmatically get previous/next animation in PowerPoint VBA

I am trying to control slide animations from action buttons in PowerPoint VBA. I manage to navigate to next and previous animations in the current slide using sendKeys.

The action buttons basically runs displayPrevious and displayNext macros as follows:

Sub displayPrevious()
    SendKeys ("{LEFT}")
End Sub

Sub displayNext(ByRef oShp As Shape)
    SendKeys ("{RIGHT}")
End Sub

However, this results in an unwanted feature. After the last animation the next button switch the next or previous slide.

One way I am thinking to do this is maybe, get the next or previous to be executed and if its a change slide just don't run the sendkeys.

Or maybe I am thinking this the wrong way and there can be an easier solution?

Upvotes: 0

Views: 861

Answers (1)

Tarounen
Tarounen

Reputation: 1159

Finally managed to find a (working but not perfect) solution.

Basically just checking the current animation being played from getClickIndex and comparing to 0 for previous and getClickCount for next.

Sub displayPrevious()
   If ActivePresentation.SlideShowWindow.View.GetClickIndex <> 0 Then
        SendKeys ("{LEFT}")
    End If
End Sub

Sub displayNext()
    If ActivePresentation.SlideShowWindow.View.GetClickIndex <> ActivePresentation.SlideShowWindow.View.GetClickCount Then
        SendKeys ("{RIGHT}")
    End If
End Sub

Upvotes: 1

Related Questions