Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default Playing sound in VBA

Hi
Somebody please help.
I had a look at John Walkenbach's site and copied off some code to play a
wave file.
I run Excel 2003 under Windows XP Home
I can play the different sounds perfectly when clicking on the various wave
files (it automatically launches Windows Media Player)

However when I run the code below I get the same dull 'clunck' no matter
what wave file I put in (WAVFile) - its always the same!
I did do a search for "winmm.dll" but could not locate it on my system. Is
this the problem or am I doing something else wrong?
Is there perhaps a library that I need to tick off?
I also tried running the code on another PC with the same result.

Desperate Pete

'=============================
Option Explicit
Private Declare Function PlaySound Lib "winmm.dll" (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()
Dim WAVFile As String
If Not Application.CanPlaySounds Then
MsgBox "Sorry, sound is not supported on your system."
Else
WAVFile = "C:\Windows\Media\Microsoft Office 2000\Chimes.wav"
Call PlaySound(WAVFile, 0&, SND_ASYNC Or SND_FILENAME)
End If
End Sub
'============================


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Playing sound in VBA

Maybe a long shot, but try this slight variation

Option Explicit
Private Declare Function PlaySound Lib "winmm.dll" ( _
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()
Dim WAVFile As String
If Not Application.CanPlaySounds Then
MsgBox "Sorry, sound is not supported on your system."
Else
WAVFile = "C:\Windows\Media\Microsoft Office 2000\Chimes.wav"
Call PlaySound(WAVFile, 0&, SND_ASYNC Or SND_FILENAME)
End If
End Sub


--
HTH

Bob Phillips

"Pete" wrote in message
...
Hi
Somebody please help.
I had a look at John Walkenbach's site and copied off some code to play a
wave file.
I run Excel 2003 under Windows XP Home
I can play the different sounds perfectly when clicking on the various

wave
files (it automatically launches Windows Media Player)

However when I run the code below I get the same dull 'clunck' no matter
what wave file I put in (WAVFile) - its always the same!
I did do a search for "winmm.dll" but could not locate it on my system.

Is
this the problem or am I doing something else wrong?
Is there perhaps a library that I need to tick off?
I also tried running the code on another PC with the same result.

Desperate Pete

'=============================
Option Explicit
Private Declare Function PlaySound Lib "winmm.dll" (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()
Dim WAVFile As String
If Not Application.CanPlaySounds Then
MsgBox "Sorry, sound is not supported on your system."
Else
WAVFile = "C:\Windows\Media\Microsoft Office 2000\Chimes.wav"
Call PlaySound(WAVFile, 0&, SND_ASYNC Or SND_FILENAME)
End If
End Sub
'============================




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default Playing sound in VBA

'Fraid it made no difference. Thanks for trying, Bob.

"Bob Phillips" wrote in message
...
Maybe a long shot, but try this slight variation

Option Explicit
Private Declare Function PlaySound Lib "winmm.dll" ( _
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()
Dim WAVFile As String
If Not Application.CanPlaySounds Then
MsgBox "Sorry, sound is not supported on your system."
Else
WAVFile = "C:\Windows\Media\Microsoft Office 2000\Chimes.wav"
Call PlaySound(WAVFile, 0&, SND_ASYNC Or SND_FILENAME)
End If
End Sub


--
HTH

Bob Phillips

"Pete" wrote in message
...
Hi
Somebody please help.
I had a look at John Walkenbach's site and copied off some code to play a
wave file.
I run Excel 2003 under Windows XP Home
I can play the different sounds perfectly when clicking on the various

wave
files (it automatically launches Windows Media Player)

However when I run the code below I get the same dull 'clunck' no matter
what wave file I put in (WAVFile) - its always the same!
I did do a search for "winmm.dll" but could not locate it on my system.

Is
this the problem or am I doing something else wrong?
Is there perhaps a library that I need to tick off?
I also tried running the code on another PC with the same result.

Desperate Pete

'=============================
Option Explicit
Private Declare Function PlaySound Lib "winmm.dll" (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()
Dim WAVFile As String
If Not Application.CanPlaySounds Then
MsgBox "Sorry, sound is not supported on your system."
Else
WAVFile = "C:\Windows\Media\Microsoft Office 2000\Chimes.wav"
Call PlaySound(WAVFile, 0&, SND_ASYNC Or SND_FILENAME)
End If
End Sub
'============================






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 903
Default Playing sound in VBA

Hi Pete,
See if this helps, been a long time since I've played with it
http://www.mvps.org/dmcritchie/excel/code/beeps.txt

Actually starts from my funstuff.htm#sounds_xl a non indexed
page in my Excel directory.
---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm


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
How do I keep the ding sound from playing when a message appears? Quinn1984 Excel Discussion (Misc queries) 2 September 12th 07 01:04 PM
Playing a sound file from entry in cell NG99 Excel Discussion (Misc queries) 2 January 31st 07 12:27 AM
Problem with playing sound code EMoe[_39_] Excel Programming 3 July 6th 05 01:30 AM
playing sound??? tess457[_6_] Excel Programming 2 October 20th 04 11:50 AM
Playing a sound base on cell value Mike[_58_] Excel Programming 4 November 30th 03 03:53 AM


All times are GMT +1. The time now is 09:15 AM.

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

About Us

"It's about Microsoft Excel"