ByX 属性

       

设置或返回 Single 类型值,该值代表按指定的屏幕宽度百分比水平缩放或移动对象,缩放或移动取决于该属性是与 MotionEffect 对象还是与 ScaleEffect 对象联合使用。例如,动作效果值 50 表示将对象向右移动屏幕宽度一半的距离。可读写。

expression.ByX

expression  必选。该表达式返回“应用于”列表中的对象之一。

说明

负数表示水平向左移动对象。浮点数(例如 55.5)有效。

若要垂直缩放或移动对象,请使用 ByY 属性。

如果同时设置 ByXByY 属性,则可以在水平和垂直两个方向缩放或移动对象。

请勿将此属性与 ColorEffectRotationEffectPropertyEffect 对象的 By 属性相混淆,它们分别用于设置动画动作的颜色、旋转或其他属性。

示例

以下示例添加了一个动画路径;然后设置形状在水平和垂直方向上的移动。

Sub AddMotionPath()

    Dim effCustom As Effect
    Dim animBehavior As AnimationBehavior
    Dim shpRectangle As Shape

    'Adds rectangle and sets effect and animation
    Set shpRectangle = ActivePresentation.Slides(1).Shapes _
        .AddShape(Type:=msoShapeRectangle, Left:=300, _
        Top:=300, Width:=300, Height:=150)
    Set effCustom = ActivePresentation.Slides(1).TimeLine _
        .MainSequence.AddEffect(Shape:=shpRectangle, _
         effectId:=msoAnimEffectCustom)
    Set animBehavior = effCustom.Behaviors.Add(msoAnimTypeMotion)

    'Specifies animation motion
    With animBehavior.MotionEffect
        .ByX = 50
        .ByY = 50
    End With

End Sub