Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Playing a WAV file in Excel 2002


I have the following code to play a WAV file in excel:

Sub PlayWavFile(WavFileName As String, Wait As Boolean)
If Dir(WavFileName) = "" Then Exit Sub ' no file to play
If Wait Then ' play sound before running any more code
sndPlaySound WavFileName, 0
Else ' play sound while code is running
sndPlaySound WavFileName, 1
End If
End Sub

where the file name is c:\accounts\05\temp\sound.wmv

I am really struggling to put this macro together, can anyone lay it
out in a slightly easier to follow format?

Thanks
chris


--
chalky
------------------------------------------------------------------------
chalky's Profile: http://www.excelforum.com/member.php...o&userid=23758
View this thread: http://www.excelforum.com/showthread...hreadid=504003

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Playing a WAV file in Excel 2002

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

John Walkenbach's page on playing a wav or midi sound.

--
Regards,
Tom Ogilvy




"chalky" wrote in
message ...

I have the following code to play a WAV file in excel:

Sub PlayWavFile(WavFileName As String, Wait As Boolean)
If Dir(WavFileName) = "" Then Exit Sub ' no file to play
If Wait Then ' play sound before running any more code
sndPlaySound WavFileName, 0
Else ' play sound while code is running
sndPlaySound WavFileName, 1
End If
End Sub

where the file name is c:\accounts\05\temp\sound.wmv

I am really struggling to put this macro together, can anyone lay it
out in a slightly easier to follow format?

Thanks
chris


--
chalky
------------------------------------------------------------------------
chalky's Profile:

http://www.excelforum.com/member.php...o&userid=23758
View this thread: http://www.excelforum.com/showthread...hreadid=504003



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Playing a WAV file in Excel 2002


Ah thanks for this - no wonder it wasnt working, my system isnt
supporting it.

Thanks
Chris


--
chalky
------------------------------------------------------------------------
chalky's Profile: http://www.excelforum.com/member.php...o&userid=23758
View this thread: http://www.excelforum.com/showthread...hreadid=504003

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Playing a WAV file in Excel 2002


I have managed to procure a laptop wherre this macro looks like it will
work fine. The formula used is as follows:

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 PlayWAV()
WAVFile = "Noise-2.wav"
WAVFile = ThisWorkbook.Path & "\" & WAVFile
Call PlaySound(WAVFile, 0&, SND_ASYNC Or SND_FILENAME)
End Sub

However, when i run it i get the following error:

run-time error '453'

Can't find DLL entry point playsounda in winmm.dll

Any ideas?


--
chalky
------------------------------------------------------------------------
chalky's Profile: http://www.excelforum.com/member.php...o&userid=23758
View this thread: http://www.excelforum.com/showthread...hreadid=504003

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Playing a WAV file in Excel 2002

Best I can tell you is that this worked fine for me:

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 PlayWAV()
'WAVFile = "Noise-2.wav"
WAVFile = "C:\WINDOWS\MEDIA\Chimes.wav"
Call PlaySound(WAVFile, 0&, SND_ASYNC Or SND_FILENAME)
End Sub

Windows XP Professional
Excel 2003

--
Regards,
Tom Ogilvy

"chalky" wrote in
message ...

I have managed to procure a laptop wherre this macro looks like it will
work fine. The formula used is as follows:

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 PlayWAV()
WAVFile = "Noise-2.wav"
WAVFile = ThisWorkbook.Path & "\" & WAVFile
Call PlaySound(WAVFile, 0&, SND_ASYNC Or SND_FILENAME)
End Sub

However, when i run it i get the following error:

run-time error '453'

Can't find DLL entry point playsounda in winmm.dll

Any ideas?


--
chalky
------------------------------------------------------------------------
chalky's Profile:

http://www.excelforum.com/member.php...o&userid=23758
View this thread: http://www.excelforum.com/showthread...hreadid=504003





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Playing a WAV file in Excel 2002

Also worked unchanged in

Windows 98 SE
Excel 97

--
Regards,
Tom Ogilvy

"Tom Ogilvy" wrote in message
...
Best I can tell you is that this worked fine for me:

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 PlayWAV()
'WAVFile = "Noise-2.wav"
WAVFile = "C:\WINDOWS\MEDIA\Chimes.wav"
Call PlaySound(WAVFile, 0&, SND_ASYNC Or SND_FILENAME)
End Sub

Windows XP Professional
Excel 2003

--
Regards,
Tom Ogilvy

"chalky" wrote in
message ...

I have managed to procure a laptop wherre this macro looks like it will
work fine. The formula used is as follows:

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 PlayWAV()
WAVFile = "Noise-2.wav"
WAVFile = ThisWorkbook.Path & "\" & WAVFile
Call PlaySound(WAVFile, 0&, SND_ASYNC Or SND_FILENAME)
End Sub

However, when i run it i get the following error:

run-time error '453'

Can't find DLL entry point playsounda in winmm.dll

Any ideas?


--
chalky
------------------------------------------------------------------------
chalky's Profile:

http://www.excelforum.com/member.php...o&userid=23758
View this thread:

http://www.excelforum.com/showthread...hreadid=504003





  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Playing a WAV file in Excel 2002


This code seems to be running the macro now but no sound is coming out!
I have checked the volume and that is fine - i am at a lose!


--
chalky
------------------------------------------------------------------------
chalky's Profile: http://www.excelforum.com/member.php...o&userid=23758
View this thread: http://www.excelforum.com/showthread...hreadid=504003

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Playing a WAV file in Excel 2002

Do you get sounds otherwise? If not, perhaps you have mute turned on.

--
Regards,
Tom Ogilvy


"chalky" wrote in
message ...

This code seems to be running the macro now but no sound is coming out!
I have checked the volume and that is fine - i am at a lose!


--
chalky
------------------------------------------------------------------------
chalky's Profile:

http://www.excelforum.com/member.php...o&userid=23758
View this thread: http://www.excelforum.com/showthread...hreadid=504003



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
Playing an audio file in Excel Fuji0664 Excel Discussion (Misc queries) 2 October 23rd 09 03:55 AM
Detecting the actual playing or NOT playing of a WAV file Bajbaj Excel Discussion (Misc queries) 0 October 24th 07 09:16 PM
Excel 2002: How is the Excel 2007 file format open in Excel 2002 ? Mr. Low Excel Discussion (Misc queries) 2 August 29th 07 11:46 PM
Playing a sound file from entry in cell NG99 Excel Discussion (Misc queries) 2 January 31st 07 12:27 AM
Playing a embedded wav file when excel opens Waving Hello Excel Discussion (Misc queries) 1 April 14th 06 08:27 PM


All times are GMT +1. The time now is 06:59 AM.

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"