Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2
Default Playing a sound file from entry in cell

I have recently used and adapted code from a post on here which is shown
below and works great. However does anybody know how I can (or if it can be
done?) adapt this further so that entering a different "name" plays a
different sound file in the same cell i.e. C7 in this case.

Many thanks,
Nige


Option Explicit
Private Declare Function sndPlaySound32 Lib "winmm.dll" Alias _
"sndPlaySoundA" (ByVal lpszSoundName As String, _
ByVal uFlags As Long) As Long

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$C$7" Then
If Target.Value = "Lawrence" Then
sndPlaySound32 "C:\Documents and Settings\LAPTOP\My Documents\homer_31.wav", 0
End If
End If
End Sub
--
NG99
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Playing a sound file from entry in cell

Maybe...

Option Explicit
Private Declare Function sndPlaySound32 Lib "winmm.dll" Alias _
"sndPlaySoundA" (ByVal lpszSoundName As String, _
ByVal uFlags As Long) As Long

Private Sub Worksheet_Change(ByVal Target As Range)
dim mySoundFile as string
dim myFolder as string

myFolder = "C:\Documents and Settings\LAPTOP\My Documents\"

mysoundfile = ""
If Target.Address = "$C$7" Then
select case lcase(target.value)
case is = "lawrence" :mysoundfile = "homer_31.wav"
case is = "jimmy" : mysoundfile = "triple.wav"
end select
end if

if mysoundfile = "" then
'do nothing
else
sndPlaySound32 myfolder & mysoundfile, 0
end if

End Sub

=========
If you're using xl2002+, you may want to try:

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$C$7" Then
Application.Speech.Speak Target.Value
End If
End Sub


NG99 wrote:

I have recently used and adapted code from a post on here which is shown
below and works great. However does anybody know how I can (or if it can be
done?) adapt this further so that entering a different "name" plays a
different sound file in the same cell i.e. C7 in this case.

Many thanks,
Nige

Option Explicit
Private Declare Function sndPlaySound32 Lib "winmm.dll" Alias _
"sndPlaySoundA" (ByVal lpszSoundName As String, _
ByVal uFlags As Long) As Long

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$C$7" Then
If Target.Value = "Lawrence" Then
sndPlaySound32 "C:\Documents and Settings\LAPTOP\My Documents\homer_31.wav", 0
End If
End If
End Sub
--
NG99


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2
Default Playing a sound file from entry in cell

Dave,

That works a treat thanks for your very prompt help!
--
NG99


"Dave Peterson" wrote:

Maybe...

Option Explicit
Private Declare Function sndPlaySound32 Lib "winmm.dll" Alias _
"sndPlaySoundA" (ByVal lpszSoundName As String, _
ByVal uFlags As Long) As Long

Private Sub Worksheet_Change(ByVal Target As Range)
dim mySoundFile as string
dim myFolder as string

myFolder = "C:\Documents and Settings\LAPTOP\My Documents\"

mysoundfile = ""
If Target.Address = "$C$7" Then
select case lcase(target.value)
case is = "lawrence" :mysoundfile = "homer_31.wav"
case is = "jimmy" : mysoundfile = "triple.wav"
end select
end if

if mysoundfile = "" then
'do nothing
else
sndPlaySound32 myfolder & mysoundfile, 0
end if

End Sub

=========
If you're using xl2002+, you may want to try:

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$C$7" Then
Application.Speech.Speak Target.Value
End If
End Sub


NG99 wrote:

I have recently used and adapted code from a post on here which is shown
below and works great. However does anybody know how I can (or if it can be
done?) adapt this further so that entering a different "name" plays a
different sound file in the same cell i.e. C7 in this case.

Many thanks,
Nige

Option Explicit
Private Declare Function sndPlaySound32 Lib "winmm.dll" Alias _
"sndPlaySoundA" (ByVal lpszSoundName As String, _
ByVal uFlags As Long) As Long

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$C$7" Then
If Target.Value = "Lawrence" Then
sndPlaySound32 "C:\Documents and Settings\LAPTOP\My Documents\homer_31.wav", 0
End If
End If
End Sub
--
NG99


--

Dave Peterson

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cell References [email protected] Excel Discussion (Misc queries) 2 November 16th 06 12:37 AM
Saving worksheet in new file with date AND cell value as file name michaelberrier Excel Discussion (Misc queries) 4 May 26th 06 08:05 PM
Help with this conditional IF statement C-Dawg Excel Discussion (Misc queries) 3 May 15th 06 06:01 PM
resetting last cell jagdish.eashwar Excel Discussion (Misc queries) 11 March 31st 06 02:06 AM
Using Jet to read excel file returns blank for last cell - sometim Ron Excel Discussion (Misc queries) 1 December 9th 04 09:21 AM


All times are GMT +1. The time now is 10:56 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"