Sound :: MrExcel Message Board


 FAQFAQ
   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   FavoritesFavorites   StatisticsStatistics 
 RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
Online StoreOnline Store

MrExcel Message Board Forum Index -> Excel Questions

Sound
Post new topic   Reply to topic
Last Thread | Next Thread  >   Printable version
  Author    Thread

Orangeanorak
Board Regular


Joined: 23 Nov 2002
Posts: 62
Location: Belfast
Flag: Blank

Status: Offline

 Reply with quote  

Sound

Cqn you please tell me how to make a sound play if a certain phrase appears in a cell i.e if John 2 appears in cell L5 play sound. The microsoft sounds will do. Thanks John icon_iwantatten.gif

Post Sat Sep 20, 2003 12:35 pm 
 View user's profile Send private message Send e-mail Visit poster's website

Richie(UK)
MrExcel MVP


Joined: 18 May 2002
Posts: 2464
Location: Worcester, England
Flag: Uk

Status: Offline

 Reply with quote  

Re: Sound

Hi John,

Take a look at the 'Alarm' function at JWalk:

http://www.j-walk.com/ss/excel/tips/tip87.htm

HTH
_________________
Richie

Post Sat Sep 20, 2003 1:05 pm 
 View user's profile Send private message

George J
Board Master


Joined: 16 Feb 2002
Posts: 375
Location: Edinburgh, Bonnie Scotland
Flag: Scotland

Status: Offline

 Reply with quote  

Re: Sound

For wav files - In the sheet code


Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("l5")) Is Nothing Then
Exit Sub
Else

If Cells(5, 12) = "John2" Then

Call PlaySound("D:\D Drive\GEORGE\Music\music\duel_a.wav", 0)

End If
End If
End Sub


and in a module

Declare Function PlaySound Lib "winmm.dll" Alias _
"sndPlaySoundA" (ByVal wavFile As String, _
ByVal lNum As Long) As Long
_________________
George J

Post Sat Sep 20, 2003 1:09 pm 
 View user's profile Send private message Send e-mail

HalfAce
Board Master


Joined: 07 Apr 2003
Posts: 685
Location: Cordova, Alaska
Flag: Blank

Status: Offline

 Reply with quote  

Re: Sound

Hi George,
Was just checking this out and wondering if you know how to have these same conditions ("John2" in L5 for instance) make it play some actual music (like an MP3 from the hard drive), instead of just one of the standard windows noises. I'm thinking the change would be in the code in the standard module (somewhere in the area of "winmm.dll" Alias _ "sndPlaySoundA") and the path in my sheet module code would be more like: "C:\Program Files\Music Folder\Song Name.MP3. Do you know of a way to do this also?

Thanks,
HalfAce

Post Sat Sep 20, 2003 6:48 pm 
 View user's profile Send private message

George J
Board Master


Joined: 16 Feb 2002
Posts: 375
Location: Edinburgh, Bonnie Scotland
Flag: Scotland

Status: Offline

 Reply with quote  

Re: Sound

The wav file was an actual song from my hard drive, but the following works just as well

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
If ActiveCell.Text = "" Then
Exit Sub
Else
Cmd = "Start " & Chr(34) & ActiveCell.Text & Chr(34)
Shell Cmd
On Error Resume Next
End If
End Sub

If you put the full name and path in the cell it will play
eg C3 is C:\Program Files\Music Folder\Song Name.mp3

You will have to be a bit patient in waiting for your player to load up however.
_________________
George J

Post Sat Sep 20, 2003 7:49 pm 
 View user's profile Send private message Send e-mail
  Display posts from previous:      

MrExcel Message Board Forum Index -> Excel Questions


Forum Jump:
Jump to:  

Post new topic   Reply to topic
Page 1 of 1



Add To Favorites

 


Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpBB: 2.0.4 © 2001 phpBB Group

Need help posting your first question? Read how to post

Need extra help ? Couldn't get the answer you needed ? Get a free quote from our Consulting Team

Download Colo's HTML Maker utility for displaying your Excel Worksheet on the board.

Download VB HTML Maker to post your code on the board


Check out our new index to 485 Excel Articles.


Return to MrExcel Consulting

All contents Copyright 1998-2004 by MrExcel.com
If you believe information posted here is from your copyrighted source, notify us per the Terms of Use
Excel is a registered trademark of the Microsoft Corporation.
MrExcel is a registered trademark of Tickling Keys, Inc.