Re: function PlaySound does not work
- From: "expvb" <nobody@xxxxxxx>
- Date: Fri, 22 Sep 2006 20:20:59 -0400
"Susanne Wenzel" <wirdnichtgelesen@xxxxxxxxxxxxx> wrote in message
news:1xqpw086ku6pa$.dlg@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi to everyone,
I have no idea whether this group is the right one for my problem so I
just
try (and maybe I'm lucky:-)
I'm getting nowhere in trying to play a .wav-file using the function
Playsound. There's no sound, no noise to be heard when I use this function
in vb(a), actually excel-vba, same thing happens in delphi. It does not
matter if I step through the code one by one or start it via GUI. If I try
via Single-Step-Mode (I hope I've translated it somewhere near the correct
one) at least he (i.e. my computer) takes a little time until he proceeds
to the next step. As if he was doing something... The return-code I'm
getting is 1, so he thinks he's successful.
Nowhere did I cross out anything in the sound volume. If I start the
.wav-file by doubleclick in the explorer, I can hear the sound loud and
clearly, no problem.
I have no idea where to look to solve this little but nevertheless
annoying
problem. I know from several other users that they had no problems using
my
little function: they could start the .wav-file via vba and heard it.:-)
But I can't.:-(
Does anyone here have an idea or just a link for me?
Any help would be appreciated.
This is the code I used... to no avail:-(
Declare Function sndPlaySound32 Lib "winmm.dll" Alias "sndPlaySoundA"
(ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
Public Sub Klang()
Dim a
a = sndPlaySound32("C:\WINNT\Media\tada.wav", 0)
Debug.Print a
End Sub
Thanks for reading
Greetings from Germany
Susanne
--
Mein System:
Office XP, SP3, aktueller Patchstand
Windows 2000, SP4, aktueller Patchstand
Your code works fine in my system, Windows XP. I changed the file path
because Windows XP uses "C:\Windows" instead of "C:\WINNT". Here is the
revised code:
Public Sub Klang()
Dim a
a = sndPlaySound32("C:\Windows\Media\tada.wav", 0)
Debug.Print a
End Sub
Why not using PlaySound()? Try this example:
Public Const SND_APPLICATION As Long = &H80
Public Const SND_ALIAS As Long = &H10000
Public Const SND_ALIAS_ID As Long = &H110000
Public Const SND_ASYNC As Long = &H1
Public Const SND_FILENAME As Long = &H20000
Public Const SND_LOOP As Long = &H8
Public Const SND_MEMORY As Long = &H4
Public Const SND_NODEFAULT As Long = &H2
Public Const SND_NOSTOP As Long = &H10
Public Const SND_NOWAIT As Long = &H2000
Public Const SND_PURGE As Long = &H40
Public Const SND_RESOURCE As Long = &H40004
Public Const SND_SYNC As Long = &H0
Public Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" ( _
ByVal lpszName As String, _
ByVal hModule As Long, _
ByVal dwFlags As Long) As Long
Public Sub Klang()
Dim a As Long
a = PlaySound("C:\WINNT\Media\tada.wav", 0, SND_ASYNC)
Debug.Print a
End Sub
.
- Follow-Ups:
- Re: function PlaySound does not work
- From: Susanne Wenzel
- Re: function PlaySound does not work
- References:
- function PlaySound does not work
- From: Susanne Wenzel
- function PlaySound does not work
- Prev by Date: Re: NetShareAdd Error 123
- Next by Date: Re: function PlaySound does not work
- Previous by thread: function PlaySound does not work
- Next by thread: Re: function PlaySound does not work
- Index(es):
Relevant Pages
|