Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / General PowerPoint Questions / December 2007

Tip: Looking for answers? Try searching our database.

play sound in VBA

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bert - 22 Dec 2007 13:00 GMT
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
John Wilson - 22 Dec 2007 13:17 GMT
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
Signature

Amazing PPT Hints, Tips and Tutorials

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

> 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
[quoted text clipped - 10 lines]
>        End With
> End Sub
Bert - 22 Dec 2007 18:03 GMT
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

> There's no need for any code to do this.
>
[quoted text clipped - 24 lines]
>>        End With
>> End Sub
Steve Rindsberg - 22 Dec 2007 22:13 GMT
> 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.

> Thanks again.
> Bert
[quoted text clipped - 27 lines]
> >>        End With
> >> End Sub

-----------------------------------------
Steve Rindsberg, PPT MVP
PPT FAQ:  www.pptfaq.com
PPTools:  www.pptools.com
================================================
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.