是否可以从VBA代码触发形状动画?
POM
答案 0 :(得分:1)
POM,
在低于powerpoint 2010的任何版本中,似乎都不可能:http://www.pptalchemy.co.uk/vba_Triggers.html。
但是,如果您使用的是powerpoint 2010,则MSDN会详细说明straightforward demo以触发powerpoint中的形状动画:
Sub TestShapeAnimation()
With ActivePresentation.Slides(1)
Dim shp1, shp2, shp3 As Shape
' This sets the initial shape, with which we will test the animation sequences.
Set shp1 = .Shapes.AddShape(msoShape12pointStar, 20, 20, 100, 100)
' This creates the animations.
.TimeLine.MainSequence.AddEffect shp1, msoAnimEffectFadedSwivel, , msoAnimTriggerAfterPrevious
.TimeLine.MainSequence.AddEffect shp1, msoAnimEffectPathBounceRight, , msoAnimTriggerAfterPrevious
.TimeLine.MainSequence.AddEffect shp1, msoAnimEffectSpin, , msoAnimTriggerAfterPrevious
' This acquires the animation... [i]
shp1.PickupAnimation
' [i] ... and applies it to another shape.
Set shp2 = .Shapes.AddShape(msoShapeHexagon, 100, 20, 100, 100)
shp2.ApplyAnimation
' Another shape creation / animation application.
Set shp3 = .Shapes.AddShape(msoShapeCloud, 180, 20, 100, 100)
shp3.ApplyAnimation
End With
End Sub
如果您有其他问题/想法,请告诉我 -
〜JOL
答案 1 :(得分:1)
遗憾的是,JackOrangeLantern的回复对原始问题并不特别敏感。 JOL的回复将帮助您在时间轴上复制动画并将其应用于不同的形状,但它实际上不会触发它们。
如果您使用的是Powerpoint 2010或更早版本,则没有直接方法可以使用VBA实际触发动画。我对Powerpoint的新版本不是很熟悉,但我也不认为他们有这个功能。
实际上触发交互式动画似乎需要实际的鼠标点击,如果没有一些可能涉及实际搞乱Windows API的高级和过于复杂的编码,就无法在Powerpoint中轻松模拟。我发现的最好的解决方法是不要将鼠标点击发送到幻灯片上的形状,而是发送键盘笔划。
我从PPT Alchemy Mouseover trigger an animation with vba code
中发现了这个解决方案Sub anim()
SendKeys("{TAB}")
SendKeys("{ENTER}")
End Sub
此代码将激活幻灯片上的第一个交互式触发器。要激活幻灯片上的第二个触发动画,您将发送{TAB}键两次而不是一次。这绝对是在powerpoint幻灯片上激活触发动画的最简单方法。遗憾的是,没有比这更好的方法了。
请点击链接以获得更详尽的解释 照顾自己。 :)