stupidclub 发表于 2017-2-18 12:21:12

触发器选择图形对象


1、在我的第一张幻灯片中,有个图形(蓝色的矩形),名称:ActiveWindow.Selection.SlideRange.Shapes("Rectangle5"),动画中叫“矩形 2”;另一个图形(红色的圆),名称为ActiveWindow.Selection.SlideRange.Shapes("Oval6"),动画中叫“椭圆 3”。
2、矩形2已有动画“陀螺旋”,我想为它设置触发器对象的属性,就是:点击椭圆3就出现矩形2的“陀螺旋”。
3、ppt2003编辑模式手工设置比较方便,请问:用vba如何用程序设置?谢谢!
4、另这个程序好像不成功,主要的是代码第6行,有问题,请大侠帮我修改下。特别谢谢!

[*]Private Sub CommandButton1_Click()
[*]Set sld = ActiveWindow.View.Slide
[*]Set shp = ActiveWindow.Selection.SlideRange.Shapes("Rectangle 5") '选择图形
[*]Set seq = sld.TimeLine.MainSequence
[*]With seq(1)
[*] .Timing.TriggerShape = ActiveWindow.Selection.SlideRange.Shapes("Oval 6")
[*]End WithEnd Sub

复制代码
附件:

raininsnow 发表于 2017-2-18 13:34:40


自动设置触发器

[*]Sub AddShapeSetTiming() '自动设置触发器
[*]    Dim eff As Effect
[*]    Dim shpOval As Shape '椭圆
[*]    Dim shpRectangle As Shape '矩形
[*]    Set shpOval = ActivePresentation.Slides(1).Shapes. _
[*]      AddShape(Type:=msoShapeOval, Left:=400, Top:=100, Width:=100, Height:=50)
[*]
[*]    Set shpRectangle = ActivePresentation.Slides(1).Shapes. _
[*]      AddShape(Type:=msoShapeRectangle, Left:=100, Top:=100, Width:=50, Height:=50)
[*]
[*]    Set eff = ActivePresentation.Slides(1).TimeLine. _
[*]      InteractiveSequences.Add().AddEffect(Shape:=shpRectangle, _
[*]      effectId:=msoAnimEffectSpin, trigger:=msoAnimTriggerOnShapeClick)
[*]
[*]    With eff.Timing
[*]      .Duration = 8
[*]      .TriggerShape = shpOval
[*]      .TriggerType = msoAnimTriggerOnShapeClick
[*]    End WithEnd Sub

复制代码
页: [1]
查看完整版本: 触发器选择图形对象