#1   Report Post  
Posted to microsoft.public.excel.programming
Art Art is offline
external usenet poster
 
Posts: 587
Default PlayWavFile

Hello:

Does anybody know if there is any issues or problems with function
"PlayWavFile" in 2007? I tried using this but it keeps telling me function
not defined. Please help.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default PlayWavFile

Art,

Sounds like the declaration was lost:

Declare Function PlayWavFile Lib "winmm.dll" Alias _
"sndPlaySoundA" (ByVal lpszSoundName As String, _
ByVal uFlags As Long) As Long


Sub PlayMySound()
Call PlayWavFile("C:\WINDOWS\MEDIA\Jungle Error.WAV", 0)
End Sub


--
HTH,
Bernie
MS Excel MVP


"art" wrote in message
...
Hello:

Does anybody know if there is any issues or problems with function
"PlayWavFile" in 2007? I tried using this but it keeps telling me function
not defined. Please help.



  #3   Report Post  
Posted to microsoft.public.excel.programming
Art Art is offline
external usenet poster
 
Posts: 587
Default PlayWavFile

I have this in the worksheet:

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

Sub PlayWavFile(WavFileName As String)
sndPlaySound WavFileName, 1
End Sub

and in the sheet module I have

Sub TestPlayWavFile()
PlayWavFile "C:\WINDOWS\Media\Windows XP Startup.Wav"
End Sub


Am I missing something? Please let me know.


"Bernie Deitrick" wrote:

Art,

Sounds like the declaration was lost:

Declare Function PlayWavFile Lib "winmm.dll" Alias _
"sndPlaySoundA" (ByVal lpszSoundName As String, _
ByVal uFlags As Long) As Long


Sub PlayMySound()
Call PlayWavFile("C:\WINDOWS\MEDIA\Jungle Error.WAV", 0)
End Sub


--
HTH,
Bernie
MS Excel MVP


"art" wrote in message
...
Hello:

Does anybody know if there is any issues or problems with function
"PlayWavFile" in 2007? I tried using this but it keeps telling me function
not defined. Please help.




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default PlayWavFile

Art,

Put it all into a regular codemodule, not in the sheet's codemodule..

HTH,
Bernie
MS Excel MVP


"art" wrote in message
...
I have this in the worksheet:

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

Sub PlayWavFile(WavFileName As String)
sndPlaySound WavFileName, 1
End Sub

and in the sheet module I have

Sub TestPlayWavFile()
PlayWavFile "C:\WINDOWS\Media\Windows XP Startup.Wav"
End Sub


Am I missing something? Please let me know.


"Bernie Deitrick" wrote:

Art,

Sounds like the declaration was lost:

Declare Function PlayWavFile Lib "winmm.dll" Alias _
"sndPlaySoundA" (ByVal lpszSoundName As String, _
ByVal uFlags As Long) As Long


Sub PlayMySound()
Call PlayWavFile("C:\WINDOWS\MEDIA\Jungle Error.WAV", 0)
End Sub


--
HTH,
Bernie
MS Excel MVP


"art" wrote in message
...
Hello:

Does anybody know if there is any issues or problems with function
"PlayWavFile" in 2007? I tried using this but it keeps telling me function
not defined. Please help.






  #5   Report Post  
Posted to microsoft.public.excel.programming
Art Art is offline
external usenet poster
 
Posts: 587
Default PlayWavFile

Can you please give me the whole code in one length since I'm not so famiar
with it. I tried but there is something wrong I'm doing. So please give me
the whole code I should use.

Thanks.

"Bernie Deitrick" wrote:

Art,

Put it all into a regular codemodule, not in the sheet's codemodule..

HTH,
Bernie
MS Excel MVP


"art" wrote in message
...
I have this in the worksheet:

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

Sub PlayWavFile(WavFileName As String)
sndPlaySound WavFileName, 1
End Sub

and in the sheet module I have

Sub TestPlayWavFile()
PlayWavFile "C:\WINDOWS\Media\Windows XP Startup.Wav"
End Sub


Am I missing something? Please let me know.


"Bernie Deitrick" wrote:

Art,

Sounds like the declaration was lost:

Declare Function PlayWavFile Lib "winmm.dll" Alias _
"sndPlaySoundA" (ByVal lpszSoundName As String, _
ByVal uFlags As Long) As Long


Sub PlayMySound()
Call PlayWavFile("C:\WINDOWS\MEDIA\Jungle Error.WAV", 0)
End Sub


--
HTH,
Bernie
MS Excel MVP


"art" wrote in message
...
Hello:

Does anybody know if there is any issues or problems with function
"PlayWavFile" in 2007? I tried using this but it keeps telling me function
not defined. Please help.








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default PlayWavFile

In a regular codemodule:

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

Sub PlayWavFile(WavFileName As String)
sndPlaySound WavFileName, 1
End Sub

'This is the sub to run:
Sub TestPlayWavFile()
PlayWavFile "C:\WINDOWS\Media\Windows XP Startup.Wav"
End Sub


HTH,
Bernie
MS Excel MVP


"art" wrote in message
...
Can you please give me the whole code in one length since I'm not so famiar
with it. I tried but there is something wrong I'm doing. So please give me
the whole code I should use.

Thanks.

"Bernie Deitrick" wrote:

Art,

Put it all into a regular codemodule, not in the sheet's codemodule..

HTH,
Bernie
MS Excel MVP


"art" wrote in message
...
I have this in the worksheet:

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

Sub PlayWavFile(WavFileName As String)
sndPlaySound WavFileName, 1
End Sub

and in the sheet module I have

Sub TestPlayWavFile()
PlayWavFile "C:\WINDOWS\Media\Windows XP Startup.Wav"
End Sub


Am I missing something? Please let me know.


"Bernie Deitrick" wrote:

Art,

Sounds like the declaration was lost:

Declare Function PlayWavFile Lib "winmm.dll" Alias _
"sndPlaySoundA" (ByVal lpszSoundName As String, _
ByVal uFlags As Long) As Long


Sub PlayMySound()
Call PlayWavFile("C:\WINDOWS\MEDIA\Jungle Error.WAV", 0)
End Sub


--
HTH,
Bernie
MS Excel MVP


"art" wrote in message
...
Hello:

Does anybody know if there is any issues or problems with function
"PlayWavFile" in 2007? I tried using this but it keeps telling me function
not defined. Please help.








  #7   Report Post  
Posted to microsoft.public.excel.programming
Art Art is offline
external usenet poster
 
Posts: 587
Default PlayWavFile

Do I copy and paste the whole code in vba?

I got the error message "Compile Error, Constant, fixed length strings,
arrays, user defined types and delare ststaments not allowed as public
members of object moduls".

Please help me.

"Bernie Deitrick" wrote:

In a regular codemodule:

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

Sub PlayWavFile(WavFileName As String)
sndPlaySound WavFileName, 1
End Sub

'This is the sub to run:
Sub TestPlayWavFile()
PlayWavFile "C:\WINDOWS\Media\Windows XP Startup.Wav"
End Sub


HTH,
Bernie
MS Excel MVP


"art" wrote in message
...
Can you please give me the whole code in one length since I'm not so famiar
with it. I tried but there is something wrong I'm doing. So please give me
the whole code I should use.

Thanks.

"Bernie Deitrick" wrote:

Art,

Put it all into a regular codemodule, not in the sheet's codemodule..

HTH,
Bernie
MS Excel MVP


"art" wrote in message
...
I have this in the worksheet:

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

Sub PlayWavFile(WavFileName As String)
sndPlaySound WavFileName, 1
End Sub

and in the sheet module I have

Sub TestPlayWavFile()
PlayWavFile "C:\WINDOWS\Media\Windows XP Startup.Wav"
End Sub


Am I missing something? Please let me know.


"Bernie Deitrick" wrote:

Art,

Sounds like the declaration was lost:

Declare Function PlayWavFile Lib "winmm.dll" Alias _
"sndPlaySoundA" (ByVal lpszSoundName As String, _
ByVal uFlags As Long) As Long


Sub PlayMySound()
Call PlayWavFile("C:\WINDOWS\MEDIA\Jungle Error.WAV", 0)
End Sub


--
HTH,
Bernie
MS Excel MVP


"art" wrote in message
...
Hello:

Does anybody know if there is any issues or problems with function
"PlayWavFile" in 2007? I tried using this but it keeps telling me function
not defined. Please help.









  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default PlayWavFile

Yes, copy all that code - but you are putting the code into the codemodule of either a sheet object
or the thisworkbook object, not a regular codemodule.

In the VBE, use Insert / Module and paste the code into that module.

HTH,
Bernie
MS Excel MVP


"art" wrote in message
...
Do I copy and paste the whole code in vba?

I got the error message "Compile Error, Constant, fixed length strings,
arrays, user defined types and delare ststaments not allowed as public
members of object moduls".

Please help me.

"Bernie Deitrick" wrote:

In a regular codemodule:

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

Sub PlayWavFile(WavFileName As String)
sndPlaySound WavFileName, 1
End Sub

'This is the sub to run:
Sub TestPlayWavFile()
PlayWavFile "C:\WINDOWS\Media\Windows XP Startup.Wav"
End Sub


HTH,
Bernie
MS Excel MVP


"art" wrote in message
...
Can you please give me the whole code in one length since I'm not so famiar
with it. I tried but there is something wrong I'm doing. So please give me
the whole code I should use.

Thanks.

"Bernie Deitrick" wrote:

Art,

Put it all into a regular codemodule, not in the sheet's codemodule..

HTH,
Bernie
MS Excel MVP


"art" wrote in message
...
I have this in the worksheet:

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

Sub PlayWavFile(WavFileName As String)
sndPlaySound WavFileName, 1
End Sub

and in the sheet module I have

Sub TestPlayWavFile()
PlayWavFile "C:\WINDOWS\Media\Windows XP Startup.Wav"
End Sub


Am I missing something? Please let me know.


"Bernie Deitrick" wrote:

Art,

Sounds like the declaration was lost:

Declare Function PlayWavFile Lib "winmm.dll" Alias _
"sndPlaySoundA" (ByVal lpszSoundName As String, _
ByVal uFlags As Long) As Long


Sub PlayMySound()
Call PlayWavFile("C:\WINDOWS\MEDIA\Jungle Error.WAV", 0)
End Sub


--
HTH,
Bernie
MS Excel MVP


"art" wrote in message
...
Hello:

Does anybody know if there is any issues or problems with function
"PlayWavFile" in 2007? I tried using this but it keeps telling me function
not defined. Please help.











  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default PlayWavFile

In the VB editor, click Insert/Module on the menu bar and put this part of
Bernie's code in the code window that appears...

Public Declare Function sndPlaySound Lib "winmm.dll" _
Alias "sndPlaySoundA" (ByVal lpszSoundName As String, _
ByVal uFlags As Long) As Long

Sub PlayWavFile(WavFileName As String)
sndPlaySound WavFileName, 1
End Sub

Now, in the code window for your worksheet (where I think you originally
placed Bernie's code), delete the code you got from Bernie earlier and just
put this part of it in there instead...

Sub TestPlayWavFile()
PlayWavFile "C:\WINDOWS\Media\Windows XP Startup.Wav"
End Sub

This last code is actually a substitute for your own macro if you have one.
If you have your own macro, then put the PlayWavFile statement in it and run
that macro; if you do NOT have your own macro, then just run the
TestPlayWavFile macro instead.

Rick


"art" wrote in message
...
Do I copy and paste the whole code in vba?

I got the error message "Compile Error, Constant, fixed length strings,
arrays, user defined types and delare ststaments not allowed as public
members of object moduls".

Please help me.

"Bernie Deitrick" wrote:

In a regular codemodule:

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

Sub PlayWavFile(WavFileName As String)
sndPlaySound WavFileName, 1
End Sub

'This is the sub to run:
Sub TestPlayWavFile()
PlayWavFile "C:\WINDOWS\Media\Windows XP Startup.Wav"
End Sub


HTH,
Bernie
MS Excel MVP


"art" wrote in message
...
Can you please give me the whole code in one length since I'm not so
famiar
with it. I tried but there is something wrong I'm doing. So please give
me
the whole code I should use.

Thanks.

"Bernie Deitrick" wrote:

Art,

Put it all into a regular codemodule, not in the sheet's codemodule..

HTH,
Bernie
MS Excel MVP


"art" wrote in message
...
I have this in the worksheet:

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

Sub PlayWavFile(WavFileName As String)
sndPlaySound WavFileName, 1
End Sub

and in the sheet module I have

Sub TestPlayWavFile()
PlayWavFile "C:\WINDOWS\Media\Windows XP Startup.Wav"
End Sub


Am I missing something? Please let me know.


"Bernie Deitrick" wrote:

Art,

Sounds like the declaration was lost:

Declare Function PlayWavFile Lib "winmm.dll" Alias _
"sndPlaySoundA" (ByVal lpszSoundName As String, _
ByVal uFlags As Long) As Long


Sub PlayMySound()
Call PlayWavFile("C:\WINDOWS\MEDIA\Jungle Error.WAV", 0)
End Sub


--
HTH,
Bernie
MS Excel MVP


"art" wrote in message
...
Hello:

Does anybody know if there is any issues or problems with
function
"PlayWavFile" in 2007? I tried using this but it keeps telling me
function
not defined. Please help.










  #10   Report Post  
Posted to microsoft.public.excel.programming
Art Art is offline
external usenet poster
 
Posts: 587
Default PlayWavFile

Thanks your'e the best.

"Bernie Deitrick" wrote:

Yes, copy all that code - but you are putting the code into the codemodule of either a sheet object
or the thisworkbook object, not a regular codemodule.

In the VBE, use Insert / Module and paste the code into that module.

HTH,
Bernie
MS Excel MVP


"art" wrote in message
...
Do I copy and paste the whole code in vba?

I got the error message "Compile Error, Constant, fixed length strings,
arrays, user defined types and delare ststaments not allowed as public
members of object moduls".

Please help me.

"Bernie Deitrick" wrote:

In a regular codemodule:

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

Sub PlayWavFile(WavFileName As String)
sndPlaySound WavFileName, 1
End Sub

'This is the sub to run:
Sub TestPlayWavFile()
PlayWavFile "C:\WINDOWS\Media\Windows XP Startup.Wav"
End Sub


HTH,
Bernie
MS Excel MVP


"art" wrote in message
...
Can you please give me the whole code in one length since I'm not so famiar
with it. I tried but there is something wrong I'm doing. So please give me
the whole code I should use.

Thanks.

"Bernie Deitrick" wrote:

Art,

Put it all into a regular codemodule, not in the sheet's codemodule..

HTH,
Bernie
MS Excel MVP


"art" wrote in message
...
I have this in the worksheet:

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

Sub PlayWavFile(WavFileName As String)
sndPlaySound WavFileName, 1
End Sub

and in the sheet module I have

Sub TestPlayWavFile()
PlayWavFile "C:\WINDOWS\Media\Windows XP Startup.Wav"
End Sub


Am I missing something? Please let me know.


"Bernie Deitrick" wrote:

Art,

Sounds like the declaration was lost:

Declare Function PlayWavFile Lib "winmm.dll" Alias _
"sndPlaySoundA" (ByVal lpszSoundName As String, _
ByVal uFlags As Long) As Long


Sub PlayMySound()
Call PlayWavFile("C:\WINDOWS\MEDIA\Jungle Error.WAV", 0)
End Sub


--
HTH,
Bernie
MS Excel MVP


"art" wrote in message
...
Hello:

Does anybody know if there is any issues or problems with function
"PlayWavFile" in 2007? I tried using this but it keeps telling me function
not defined. Please help.












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



All times are GMT +1. The time now is 11:30 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"