试图获得任何影响我的形状

时间:2012-08-28 22:46:18

标签: vba parameters powerpoint effect shapes

'declare Variables 
Dim osld As Slide
Dim oshp As Shape
Dim oeff As Effect

' SET objects
Set osld = ActivePresentation.Slides(7)
Set oshp = osld.Shapes("Star 1")
Set oeff = osld.TimeLine.MainSequence.AddEffect(Shape:=oshp, effectid:=msoAnimEffectChangeFillColor)

With oeff
.EffectParameters.Color2.RGB = RGB(Red:=10, Green:=45, Blue:=201)
.Timing.Duration = 2
End With

oshp.Left = oshp.Left + 100 ' Added to verify something was coming thru!

可悲的是它仍然不起作用......它编译,但对幻灯片没有影响......

我已更新代码以显示您的推荐

注意:填充颜色是在创建形状时定义的

我在形状的左侧值添加了+ 100,以确保它实际上是通过它,它确实移动但它不会改变颜色......

是否有一个“官方”列表,哪些效果支持哪些参数?

感谢您和我一起打击! :)

1 个答案:

答案 0 :(得分:1)

我理解您的挫折感:正如我的评论中所述,PowerPoint 2010中不存在Color1属性,但Color2文档中给出的示例确实使用了Color1 - 而且,因此,它不编译!

正确的方法是给 shape 一种颜色,如下所示:

oshp.Fill.ForeColor.RGB = RGB(Red:=0, Green:=0, Blue:=255)

这将是起始颜色。然后动画效果可以改变颜色:

With oeff
    .EffectParameters.Color2.RGB = RGB(Red:=0, Green:=255, Blue:=255)
    .Timing.Duration = 2
End With

请注意,TimingEffect的属性,而不是EffectParameters的属性,与问题中给出的代码相同。