play sound in VBA

  • Thread starter Thread starter Bert
  • Start date Start date
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
 
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
 
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
 
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?

It may be that the macro contains code that won't compile
Open it in the VB editor and choose Debug, Compile.

Verify your Security settings. Set macro security to medium then save your work,
close and reopen PPT and try again.
 
Back
Top