title: Find power point animation step vba
body: <p>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.</p>
  
  <p>This is my script at the moment (illustrating a radioactive source, sending out radiation in all directions)</p>
  
  <pre><code>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   
  </code></pre>
  
  <p>At the point where I would like to alter endx and endy, I have been looking for something either like</p>
  
  <pre><code>IF Activepresentation.slides(slideid).timeline.activestep&gt;=5 THEN
     dosomething()
  End if
  </code></pre>
  
  <p>or if I could make something like</p>
  
  <pre><code>Public Changed as boolean
  Sub OnSlideShowAnimationStep( .... )
    IF currentstep &gt;=5
       Changed = TRUE
    end if
  end sub
  </code></pre>
  
  <p>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?</p>