ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   playing sounds from cell value (https://www.excelbanter.com/excel-programming/303208-playing-sounds-cell-value.html)

sl[_2_]

playing sounds from cell value
 
is it possible to play a sounds from cell value in excel??



sl[_2_]

playing sounds from cell value
 
also can you stop a sound from playing with a cell value
"sl" wrote in message
...
is it possible to play a sounds from cell value in excel??




Vasant Nanavati

playing sounds from cell value
 
Not sure how you play or stop a sound with a cell value ... you need some
event to occur to trigger a macro.

--

Vasant

"sl" wrote in message
...
also can you stop a sound from playing with a cell value
"sl" wrote in message
...
is it possible to play a sounds from cell value in excel??






ste mac

playing sounds from cell value
 
Hi SL,
This is the code I use to play a sound file in excel, as long as the
soundfile is in the same workbook folder it will play it, just change
'yourwavfile' to whatever sound file you want to play...

Private Declare Function PlaySound Lib "winmm.dll" _
Alias "PlaySoundA" (ByVal lpszName As String, _
ByVal hModule As Long, ByVal dwFlags As Long) As Long

Const SND_SYNC = &H0
Const SND_ASYNC = &H1
Const SND_FILENAME = &H20000

Sub RunSLmacro()
WAVFile = "yourwavfile.wav"
WAVFile = ThisWorkbook.Path & "\" & WAVFile
Call PlaySound(WAVFile, 0&, SND_ASYNC Or SND_FILENAME)

End Sub

As for playing it when a cell value changes you could do something like:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$1" Then ' change you cell here

RunSLmacro

End If

End Sub

hope this helps...

seeya ste

sl[_2_]

playing sounds from cell value
 
that was a great help

thanks very much..


"ste mac" wrote in message
om...
Hi SL,
This is the code I use to play a sound file in excel, as long as the
soundfile is in the same workbook folder it will play it, just change
'yourwavfile' to whatever sound file you want to play...

Private Declare Function PlaySound Lib "winmm.dll" _
Alias "PlaySoundA" (ByVal lpszName As String, _
ByVal hModule As Long, ByVal dwFlags As Long) As Long

Const SND_SYNC = &H0
Const SND_ASYNC = &H1
Const SND_FILENAME = &H20000

Sub RunSLmacro()
WAVFile = "yourwavfile.wav"
WAVFile = ThisWorkbook.Path & "\" & WAVFile
Call PlaySound(WAVFile, 0&, SND_ASYNC Or SND_FILENAME)

End Sub

As for playing it when a cell value changes you could do something like:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$1" Then ' change you cell here

RunSLmacro

End If

End Sub

hope this helps...

seeya ste





All times are GMT +1. The time now is 07:26 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com