Basic Language Code to add a random sound each slide

B

Bill Dilworth

We really need more to go on.

Do you want to add sound files as transitions, animations. Do you know how
many there are? will they be formula named or will there be a list of
names?

The steps are fairly straight forward
create an array of sound name/path info
loop thru the slideshow
get a random number
insert that array position as a sound


--
Bill Dilworth
A proud member of the Microsoft PPT MVP Team
Users helping fellow users.
http://billdilworth.mvps.org
-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
vestprog2@ Please read the PowerPoint FAQ pages.
yahoo. They answer most of our questions.
com www.pptfaq.com
..
 
K

kaston3

What's the syntax to play a sound?. With a test sound 1.wav in the same
folder a tried associating a button action to a function psound()

function psound()

sndPlaySound32 ("1.wav")

/// I also tried an absolute path sndPlaySound32 ("c:\sounds\1.wav").
It does not work either

end function

Is there a comprehensive list of VBA instructions / syntax on the web?

Thanks
 
B

Bill Dilworth

This is probably the easiest way. You can add the wav files (or whatever
format) as a slide transition sound. This will cause it to play at the
beginning of each slide.

Of course you could also add it to the animation timeline, but this is a tad
more difficult to understand. You will need to add error handling and such.

----Start Code-------
Sub Tommy()
'Assuming that all the sounds are ##.wav format
' starting at 1.wav and running thru 32.wav
Const SoundFileLimit = 32

'Assuming they are all in the same directory
Const SoundPath = "c:\sounds\"

Dim oSld As Slide
For Each oSld In ActivePresentation.Slides
oSld.SlideShowTransition.SoundEffect.ImportFromFile _
SoundPath & CStr(Int(Rnd() * SoundFileLimit ) + 1) & ".wav"
Next oSld

End Sub
----End Code-------

How to open the VBE window (using code in PowerPoint)
http://billdilworth.mvps.org/opening_the_vbe.htm
 
Top