2
votes

I have a vba script that runs during presentation on a slide on a power point presentation. On the same slide, I have an animation. The script is running fine "in the background" when the animation is run, but at a certain step of the animation, I would like to change how the vba-script is run. Either by checking the timeline object or somewhere else to check how far the animation has been run, or by triggering an event when reaching the correct step, but I have not been able to find anything.

This is my script at the moment (illustrating a radioactive source, sending out radiation in all directions)

Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Public Running As Boolean ' Switched on or off by another sub

Sub DrawLines()
  Dim endx As Long
  Dim endy As Long
  Dim Slideid As Long
  Dim tetha As Double
  Dim origx As Long
  Dim origy As Long
  Dim linelength As Long
  Dim tl As TimeLine

  Slideid = 2
  origx = 100
  origy = 430
  linelength = 2000

  Dim newline As Shape
  While Running

  With ActivePresentation.Slides(Slideid).Shapes
    tetha = 2 * 3.1415 * Rnd()
    endx = Int(linelength * Sin(tetha))
    endy = Int(linelength * Cos(tetha))
    ' Here I want to alter endx and endy after a certain step in the animation

    Dim sleeptime As Long
    sleeptime = Int(500 * Rnd())
    Set newline = .AddLine(origx, origy, endx, endy)
    DoEvents ' needed to redraw
    Sleep (30)
    newline.Delete
    DoEvents  ' needed to redraw
    Sleep (sleeptime)
  End With
  Wend
End Sub   

At the point where I would like to alter endx and endy, I have been looking for something either like

IF Activepresentation.slides(slideid).timeline.activestep>=5 THEN
   dosomething()
End if

or if I could make something like

Public Changed as boolean
Sub OnSlideShowAnimationStep( .... )
  IF currentstep >=5
     Changed = TRUE
  end if
end sub

and then I can check for Changed in drawlines, but I can neither find any attribute telling me the current animation step nor any event that is fired on animation steps. Any other places I should have looked?

2

2 Answers

2
votes

If the animations are On Click you can use SlideShowWindow(1),View.GetClickCount

Otherwise you can maybe use OnSlideShowNextBuild(ByVal Wn As SlideShowWindow) to count

0
votes

I don't know about any events or ways of checking on what step or where on the timeline but you have one hack that might fix this.

when you are in your loop you can always check for the (left, top) position of the shape. And that changes while the animation run.

But on the other hand you might be able to manually iterate the animation by using the MoveTo function of the Effect object. MSDN

But I haven't used that myself.