play sound in VBA

B

Bert

I'm using PowerPoint 2003, and want to play a sound when a commandbutton is
clicked. It seems this code should work, but it doesn't. (The sound file
is in the same folder as the presentation.)
Thanks.
Bert

Private Sub CommandButton3_Click()
TextBox1.Text = TextBox1.Text + "OK"
With
ActivePresentation.Slides(1).Shapes("CommandButton3").AnimationSettings
.SoundEffect.ImportFromFile "wow.wav"
.SoundEffect.Play
End With
End Sub
 
J

John Wilson

There's no need for any code to do this.

Add an animation of sound actions > play and have it triggered by a shape or
action button.

If you are using vba after version 2000 you should never use the animation
settings object but use the timeline object instead


There's more on triggers here
http://www.pptalchemy.co.uk/powerpoint_hints_and_tips_tutorials.html#triggers
--
Amazing PPT Hints, Tips and Tutorials

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

Bert

Thanks for the information.
Now I can get the sound on a click to a "custom" action button which I've
created (ckecking off the Play sound checkbox in the Action Settings dialog
and picking the sound file), but the same button will not run a macro which
is named in the "Run Macro" box. What am I doing wrong?
Thanks again.
Bert
 

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