【问题标题】:Find power point animation step vba查找power point动画步骤vba
【发布时间】:2014-01-15 20:41:56
【问题描述】:

我有一个 vba 脚本,它在演示文稿的幻灯片演示期间运行。在同一张幻灯片上,我有一个动画。运行动画时,脚本“在后台”运行良好,但在动画的某个步骤,我想更改 vba 脚本的运行方式。通过检查时间线对象或其他地方来检查动画已经运行了多远,或者通过在到达正确步骤时触发事件,但我无法找到任何东西。

这是我目前的脚本(说明放射源,向各个方向发射辐射)

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   

在我想改变 endx 和 endy 的时候,我一直在寻找类似的东西

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

或者如果我可以制作类似的东西

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

然后我可以检查 Drawlines 中的 Changed,但我既找不到任何属性告诉我当前动画步骤,也找不到任何在动画步骤上触发的事件。还有其他我应该看的地方吗?

【问题讨论】:

    标签: vba animation powerpoint


    【解决方案1】:

    如果动画是 On Click 你可以使用 SlideShowWindow(1),View.GetClickCount

    否则你可以使用 OnSlideShowNextBuild(ByVal Wn As SlideShowWindow) 来计数

    【讨论】:

      【解决方案2】:

      我不知道有任何事件或方法可以检查时间轴上的哪个步骤或位置 但你有一个技巧可以解决这个问题。

      当您在循环中时,您可以随时检查形状的(左、上)位置。并且在动画运行时会发生变化。

      但另一方面,您可以使用 Effect 对象的 MoveTo 函数手动迭代动画。 MSDN

      但我自己没有用过。

      【讨论】:

      • 谢谢,但我正在检查的形状没有移动,它只是显示出来。 - 我试图检查它的可见属性,但总是返回 true :-/
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-01
      • 2010-09-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-10-21
      相关资源
      最近更新 更多