PDA

View Full Version : Powerpoint 2010 VBA how to rotate a "down arrow" a random number of degrees



TurboLynet
04-07-2013, 09:45 AM
Hey all

I have a problem. I have Powerpoint 2010, (thus I can't use macro recorder)

I need to code a macro that can select a figure (in this example a "down arrow") and make it rotate around its center ("like spin in the animation") a random number of degrees? But it is important that it does not return to the startformation after end running.

The random number of degrees should be simulated each time from 1 to 360 (degrees)

I have no experience with powerpoint VBA, so I need the full code!

Please help me with this problem :)

THANKS! :hi:

John Wilson
04-07-2013, 01:25 PM
Do you want this to work in edit mode or in slide show?

TurboLynet
04-07-2013, 02:00 PM
Actually both, but if this is complicated then in slide show :)

John Wilson
04-08-2013, 01:04 AM
If you know the slide number and name the shape in the selection pane (myArrow in this case)

Sub rotateMe()
Dim oshp As Shape
Dim adjRot As Integer
Dim i As Integer
adjRot = Int((Rnd * 360) + 1)
Set oshp = ActivePresentation.Slides(1).Shapes("myArrow")
With oshp
For i = 1 To adjRot
.IncrementRotation 1
DoEvents
Next i
End With
End Sub

In show mode ONLY if you give the arrow an action of run this macro

Sub rotateMeShow(oshp As Shape)
Dim adjRot As Integer
Dim i As Integer
adjRot = Int((Rnd * 360) + 1)
With oshp
For i = 1 To adjRot
.IncrementRotation 1
DoEvents
Next i
End With
End Sub