Share via

VBA shape animation

Anonymous
2014-12-03T23:58:28+00:00

I found the following code and have tried to edit it for my needs but I'm having some problems with it.  First, I'll try to explain what I'm trying to do.  I have a circle named "CircleTimer" on slide 5 of my presentation where in I'm trying to create the effect of a visual timer.  I would like to have my user be able to enter the amount of time, upon request with an input box and then when clicking the "StartTime" shape the circle would run the Exit "Wheel" effect, one spoke, clockwise for the duration the user entered.  Note: the user is prompted to enter the time in 'seconds'.  Also, I don't really want to add this effect to the slide because my user will then have to delete it afterwards, as much as I just want to run the effect.  Here's the code I found and have tried to edit. 

I get the error "Effect parameters (unknown member): Invalid Request on the line in bold.  I'm also guessing that the line for the trigger is not correct as I want the trigger to be the shape named "StartTime"

Sub ManualTimer()

Dim AmountOfTime As Integer

Dim oSld As Slide

Dim oeff As Effect

Dim oShp As Shape

AmountOfTime = InputBox("Enter the amount of time in seconds", "Time")

Set oSld = ActivePresentation.Slides(5)

Set oShp = ActivePresentation.Slides(5).Shapes("CircleTimer")

Set oeff = oSld.TimeLine.MainSequence.AddEffect _

(Shape:=oShp, effectid:=msoAnimEffectWheel, trigger:=msoAnimTriggerOnPageClick)

With oeff

    .EffectParameters.Direction = msoAnimDirectionClockwise

    .Timing.Duration = AmountOfTime

    .Exit = msoTrue

End With

End Sub

Thanks,

Mike

Microsoft 365 and Office
Microsoft 365 and Office

A comprehensive suite of productivity tools and cloud services that enhance collaboration, communication, and efficiency. Combining classic Office apps with advanced Microsoft 365 features, it supports both personal and business needs

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2014-12-05T06:56:12+00:00

Have you thought about creating the trigger animation in edit mode and then just changing the time?

Something like

Sub fixtime()

Dim oeff As Effect

Dim sngTime As Single

'in 2007 may need to reset slide

ActivePresentation.Slides(5).Shapes("CircleTimer").Visible = True

sngTime = InputBox("Set Time")

Set oeff = ActivePresentation.Slides(5).TimeLine.InteractiveSequences(1).Item(1)

oeff.Timing.Duration = sngTime

End Sub

Was this answer helpful?

0 comments No comments

Answer accepted by question author

Anonymous
2014-12-04T16:09:48+00:00

The original code won't work in PPT 2007 since AddTriggerEffect was only available from PPT 2010 onwards. The updated code below does the same such that it is PPT 2007 compatible. To make it work during presentation mode, refresh the slide after assigning the animation as shown by David Marcovitz above. See this example too: http://skp.mvps.org/pptxp012.htm#interactive

Sub ManualTimer()

  Dim AmountOfTime As Integer

  Dim oSld As Slide

  Dim oeff As Effect

  Dim oShp As Shape

  AmountOfTime = InputBox("Enter the amount of time in seconds", "Time")

  Set oSld = ActivePresentation.Slides(1)

  Set oShp = oSld.Shapes("Oval")

' Triggers are always set on the InteractiveSequence object

' I've specified the trigger to run when you click the same shape. You can change this to the desired shape.

 Set oeff = oSld.TimeLine.InteractiveSequences.Add.AddEffect(oShp, msoAnimEffectWheel, , msoAnimTriggerOnShapeClick)

  With oeff

' Specify the trigger shape here this is not needed if the trigger is on the same shape but I am doing it anyway.

        .Timing.TriggerShape = oShp

' You cannot explicit set the direction for the wheel animation, you can specify the number of spokes though.

' Set the duration after you specify Exit else it will reset.

      .EffectParameters.Amount = 1 '1 spoke

      .Exit = msoTrue

      .Timing.Duration = AmountOfTime

  End With

End Sub

Was this answer helpful?

0 comments No comments

11 additional answers

Sort by: Most helpful
  1. Anonymous
    2014-12-04T13:43:15+00:00

    Can you get the animation to work if you just refresh the slide or go to the slide with

    ActivePresentation.SlideShowWindow.View.GotoSlide _

       ActivePresentation.SlideShowWindow.View.Slide.SlideIndex

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2014-12-04T13:09:19+00:00

    Thanks for your help.  I'm having a couple of small problems. 

    First, I'm not sure if I made this clear, but I want to be able to do this while in presentation mode.  The code you gave me does work, but I can't get the trigger to work unless I exit presentation mode and then go back into it.

    My second problem is that while I have PPT 2010 at home and it all works fine except for what I mentioned above, at work I have 2007 and the code does not seem to work at all.  I get an error "Compile error: Method or data member not found on the .AddTriggerEffect

    Also note: I want the one spoke effect.

    Any suggestions?

    Mike

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2014-12-04T05:44:01+00:00

    Here you go. Comments inline.

    Sub ManualTimer()

     Dim AmountOfTime As Integer

     Dim oSld As Slide

     Dim oeff As Effect

     Dim oShp As Shape

     AmountOfTime = InputBox("Enter the amount of time in seconds", "Time")

     Set oSld = ActivePresentation.Slides(1)

     Set oShp = oSld.Shapes("Oval")

    ' Triggers are always set on the InteractiveSequence object

    ' I've specified the trigger to run when you click the same shape. You can change this to the desired shape.

     Set oeff = oSld.TimeLine.InteractiveSequences.Add.AddTriggerEffect(oShp, _

            msoAnimEffectWheel, _

            msoAnimTriggerOnShapeClick, _

            oShp)

     With oeff

    ' You cannot explicit set the direction for the wheel animation, you can specify the number of spokes though. 

    ' Set the duration after you specify Exit else it will reset.

         .Exit = msoTrue

         .Timing.Duration = AmountOfTime

     End With

     End Sub

    Was this answer helpful?

    0 comments No comments