Rotating a Group

To rotate a group using scripting, please use the following preferred method listed in the steps below.

To rotate a group using scripting:

  1. Create a variable object that is used to store the rotation angle of the group.
  2. Animate the group's rotation angle using that variable's current value as the source of the animation.
  3. Set the current value of the variable using the script instead of changing the rotation angle of the group directly.

Example: Rotating a Group Using a Script

Dim bUp As Boolean

 

Private Sub CFixPicture_Initialize()

bUp = True

CommandButton1.Caption = "Rotate Up"

End Sub

 

Private Sub CommandButton1_Click()

Dim o As Object

Dim dVal As Double

 

' get the variable object, using FindObject

' to keep group out of VBA

Set o = Me.FindObject("RotationAngle")

 

' get the current value of the variable

dVal = o.CurrentValue

 

If bUp Then

' increment the value

    dVal = dVal + 5

    

    ' if we hit 45 then rotate down next time

    If dVal = 45 Then

        bUp = False

        CommandButton1.Caption = "Rotate Down"

    End If

Else

    ' decrement the value

    dVal = dVal - 5

    

' if we hit 0 then rotate up next time

    If dVal = 0 Then

        bUp = True

        CommandButton1.Caption = "Rotate Up"

    End If

End If

 

' set the current value of the variable object

' which will result in rotating the group

o.CurrentValue = dVal

 

End Sub

See Also

How Do I...