Random spinner

G

george 16-17

Greetings,

I am in need of some assistance, as I am new to PP VBA. I found this thread
(
http://www.microsoft.com/communitie...&p=1&tid=c371ac6f-cdc3-4f37-abfd-c74d6f364f0e ) about programming a random spinner.

The suggested code in the thread above works well:

Sub RndSpin(oShp as Shape)
Dim t As Single
t = Timer + (Rnd * 4) + 1
Do Until Timer > t
oShp.Rotation = oShp.Rotation + 5
DoEvents
Loop
End Sub

But the rotating is activated by clicking on the shape that rotates.

My question is: Is there a way to click on an action button to start another
shape (an arrow) randomly spinning?

Thanks in advance and any advice is deeply appreciated,

george
 
J

John Wilson

If you know the name of the shape to spin you can easily modify the code to

Sub RndSpin()
Dim oshp As Shape
Dim t As Single
Set oshp = ActivePresentation.SlideShowWindow.View.Slide.Shapes("The Name")
t = Timer + (Rnd * 4) + 1
Do Until Timer > t
oshp.Rotation = oshp.Rotation + 5
DoEvents
Loop
Set oshp = Nothing
End Sub

It can then be triggered by any shape

The name can be read / changed easily in 2007 but in earlier versions you
may need vba

Sub myname()
MsgBox ActiveWindow.Selection.ShapeRange(1).Name
End Sub

Sub changemyname()
ActiveWindow.Selection.ShapeRange(1).Name = "myshape"
End Sub

Make sure that the name chosen is unique on that slide

--
-------------------------------------------
Amazing PPT Hints, Tips and Tutorials

http://www.PPTAlchemy.co.uk
http://www.technologytrish.co.uk
email john AT technologytrish.co.uk
 
G

george 16-17

Hi John,

That worked great. Thanks for your assistance.

I was able to rename the object and activate for an action button. Perfect!

Much appreciated!

george
 
G

george 16-17

Is it possible to have a beeping sound while the spinner is spinning?

I added the "For...Next" statement for the beep, but no sound. Here is the
code:
Sub RndSpin()
Dim oshp As Shape
Dim t As Single
Dim I
Set oshp = ActivePresentation.SlideShowWindow.View.Slide.Shapes("Spinner")
t = Timer + (Rnd * 15) + 1
Do Until Timer > t
oshp.Rotation = oshp.Rotation + 25
For I = 1 To 3 ' Loop 3 times.
Beep ' Sound a tone.
Next I
DoEvents
Loop
Set oshp = Nothing
End Sub
 
G

george 16-17

Hi Steve,

Thanks for the reply. I am still working on this project.

I have tried to write a beep command, but I have had no luck. I would be
much appreciative if you could give a little more info on how to use the beep
command.

Thanks again,
george
 
G

george 16-17

Hi Steve,

Again, your reply is much appreciated. Forget the headslap...at this point I
am banging my head against the desk. I feel really stupid that I can not get
my computer to beep, not even once.

I have used similar code and I copied and pasted your code with a separate
action button to run the marco, but still no sound. My speakers are on, as I
hear other sounds. I am missing a reference?

Thanks again,
george
 
G

george 16-17

Hi Steve,

Thanks for the reply. I did check my Control Panel and my default beep is
set to a valid sound (Windows XP Ding.wav). I can play it and actually hear
it when tested through the sound properties.

FWIW, I am using a lap top.

I will keep playing with this and try it on my home computer tonight and
report back.

Thanks for all your efforts.

george
 
G

george 16-17

Hi Steve,

I tried the beep code on my home computer and it worked fine. I am not sure
why it did not work on my work computer.

I may try forcing the WAV to play on my work computer as you suggested.

Thanks so much for your persistance with helping me.
george
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top