Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Playing sounds on opening a worksheet or shortcut

How do I link a specific wav file to a file so that when it is opened, the
sound plays for that file only.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default Playing sounds on opening a worksheet or shortcut

try this idea

Option Private Module
Declare Function sndPlaySound Lib "WINMM.DLL" Alias "sndPlaySoundA" _
(ByVal lpszSoundName As String, ByVal uFlags As Long) As Long

Sub playit()
SoundName$ = "c:\yourfolder\yourwavefilenam.wav"
wFlags% = SND_ASYNC Or SND_NODEFAULT
x% = sndPlaySound(SoundName$, wFlags%)
End Sub


--
Don Guillett
SalesAid Software

"MusicusMalus" wrote in message
...
How do I link a specific wav file to a file so that when it is opened, the
sound plays for that file only.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Playing sounds on opening a worksheet or shortcut

You might want to include the constant declarations as well:

Declare Function sndPlaySound Lib "WINMM.DLL" Alias "sndPlaySoundA" _
(ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
Const SND_SYNC = 0
Const SND_ASYNC = 1
Const SND_NODEFAULT = 2
Const SND_MEMORY = 4
Const SND_LOOP = 8
Const SND_NOSTOP = 16


Sub playit()
SoundName$ = "C:\WINDOWS\MEDIA\Jungle Asterisk.wav"
wFlags% = SND_ASYNC Or SND_NODEFAULT
x% = sndPlaySound(SoundName$, wFlags%)
End Sub

--
Regards,
Tom Ogilvy


"Don Guillett" wrote in message
...
try this idea

Option Private Module
Declare Function sndPlaySound Lib "WINMM.DLL" Alias "sndPlaySoundA" _
(ByVal lpszSoundName As String, ByVal uFlags As Long) As Long

Sub playit()
SoundName$ = "c:\yourfolder\yourwavefilenam.wav"
wFlags% = SND_ASYNC Or SND_NODEFAULT
x% = sndPlaySound(SoundName$, wFlags%)
End Sub


--
Don Guillett
SalesAid Software

"MusicusMalus" wrote in message
...
How do I link a specific wav file to a file so that when it is opened,

the
sound plays for that file only.





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Playing sounds on opening a worksheet or shortcut

Thanks for the suggestions, but I've run into a wall.

When I use the "Option Private Module" at the beginning of the code, I get
an= compile error saying, "Option Private Module not permitted in an option
module".

So whe I remove that phrase and run again using your suggested code, I get
another compile error saying, "Constants, fixed-length strings, arrays,
user-deined types and Declare statements not allowed as Public members of
object modules."

This doesn't make sense. I'm running this code as a macro in visual basic.
Anything I'm missing?

Christi

"Tom Ogilvy" wrote:

You might want to include the constant declarations as well:

Declare Function sndPlaySound Lib "WINMM.DLL" Alias "sndPlaySoundA" _
(ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
Const SND_SYNC = 0
Const SND_ASYNC = 1
Const SND_NODEFAULT = 2
Const SND_MEMORY = 4
Const SND_LOOP = 8
Const SND_NOSTOP = 16


Sub playit()
SoundName$ = "C:\WINDOWS\MEDIA\Jungle Asterisk.wav"
wFlags% = SND_ASYNC Or SND_NODEFAULT
x% = sndPlaySound(SoundName$, wFlags%)
End Sub

--
Regards,
Tom Ogilvy


"Don Guillett" wrote in message
...
try this idea

Option Private Module
Declare Function sndPlaySound Lib "WINMM.DLL" Alias "sndPlaySoundA" _
(ByVal lpszSoundName As String, ByVal uFlags As Long) As Long

Sub playit()
SoundName$ = "c:\yourfolder\yourwavefilenam.wav"
wFlags% = SND_ASYNC Or SND_NODEFAULT
x% = sndPlaySound(SoundName$, wFlags%)
End Sub


--
Don Guillett
SalesAid Software

"MusicusMalus" wrote in message
...
How do I link a specific wav file to a file so that when it is opened,

the
sound plays for that file only.






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Playing sounds on opening a worksheet or shortcut

Change the Declare statement to Private Declare.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"MusicusMalus" wrote in
message
...
Thanks for the suggestions, but I've run into a wall.

When I use the "Option Private Module" at the beginning of the
code, I get
an= compile error saying, "Option Private Module not permitted
in an option
module".

So whe I remove that phrase and run again using your suggested
code, I get
another compile error saying, "Constants, fixed-length strings,
arrays,
user-deined types and Declare statements not allowed as Public
members of
object modules."

This doesn't make sense. I'm running this code as a macro in
visual basic.
Anything I'm missing?

Christi

"Tom Ogilvy" wrote:

You might want to include the constant declarations as well:

Declare Function sndPlaySound Lib "WINMM.DLL" Alias
"sndPlaySoundA" _
(ByVal lpszSoundName As String, ByVal uFlags As Long) As
Long
Const SND_SYNC = 0
Const SND_ASYNC = 1
Const SND_NODEFAULT = 2
Const SND_MEMORY = 4
Const SND_LOOP = 8
Const SND_NOSTOP = 16


Sub playit()
SoundName$ = "C:\WINDOWS\MEDIA\Jungle Asterisk.wav"
wFlags% = SND_ASYNC Or SND_NODEFAULT
x% = sndPlaySound(SoundName$, wFlags%)
End Sub

--
Regards,
Tom Ogilvy


"Don Guillett" wrote in message
...
try this idea

Option Private Module
Declare Function sndPlaySound Lib "WINMM.DLL" Alias
"sndPlaySoundA" _
(ByVal lpszSoundName As String, ByVal uFlags As Long)
As Long

Sub playit()
SoundName$ = "c:\yourfolder\yourwavefilenam.wav"
wFlags% = SND_ASYNC Or SND_NODEFAULT
x% = sndPlaySound(SoundName$, wFlags%)
End Sub


--
Don Guillett
SalesAid Software

"MusicusMalus"
wrote in message
...
How do I link a specific wav file to a file so that when
it is opened,

the
sound plays for that file only.









  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Playing sounds on opening a worksheet or shortcut

Thanks everyone. The macro works now when I run it.

However, it doesn't automatically run when the worksheet opens (which is
what I was trying to do). I've checked my security levels to make sure they
don't interfere.

What else am I overlooking?

"Chip Pearson" wrote:

Change the Declare statement to Private Declare.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"MusicusMalus" wrote in
message
...
Thanks for the suggestions, but I've run into a wall.

When I use the "Option Private Module" at the beginning of the
code, I get
an= compile error saying, "Option Private Module not permitted
in an option
module".

So whe I remove that phrase and run again using your suggested
code, I get
another compile error saying, "Constants, fixed-length strings,
arrays,
user-deined types and Declare statements not allowed as Public
members of
object modules."

This doesn't make sense. I'm running this code as a macro in
visual basic.
Anything I'm missing?

Christi

"Tom Ogilvy" wrote:

You might want to include the constant declarations as well:

Declare Function sndPlaySound Lib "WINMM.DLL" Alias
"sndPlaySoundA" _
(ByVal lpszSoundName As String, ByVal uFlags As Long) As
Long
Const SND_SYNC = 0
Const SND_ASYNC = 1
Const SND_NODEFAULT = 2
Const SND_MEMORY = 4
Const SND_LOOP = 8
Const SND_NOSTOP = 16


Sub playit()
SoundName$ = "C:\WINDOWS\MEDIA\Jungle Asterisk.wav"
wFlags% = SND_ASYNC Or SND_NODEFAULT
x% = sndPlaySound(SoundName$, wFlags%)
End Sub

--
Regards,
Tom Ogilvy


"Don Guillett" wrote in message
...
try this idea

Option Private Module
Declare Function sndPlaySound Lib "WINMM.DLL" Alias
"sndPlaySoundA" _
(ByVal lpszSoundName As String, ByVal uFlags As Long)
As Long

Sub playit()
SoundName$ = "c:\yourfolder\yourwavefilenam.wav"
wFlags% = SND_ASYNC Or SND_NODEFAULT
x% = sndPlaySound(SoundName$, wFlags%)
End Sub


--
Don Guillett
SalesAid Software

"MusicusMalus"
wrote in message
...
How do I link a specific wav file to a file so that when
it is opened,
the
sound plays for that file only.








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
Detecting the actual playing or NOT playing of a WAV file Bajbaj Excel Discussion (Misc queries) 0 October 24th 07 09:16 PM
Using Multiple Tests and Sounds With Worksheet Macros Carl Excel Discussion (Misc queries) 3 July 1st 06 07:35 PM
Macros for playing sounds NAWBUS Excel Discussion (Misc queries) 3 December 15th 04 12:30 PM
playing sounds from cell value sl[_2_] Excel Programming 4 July 6th 04 11:15 PM
Excel XP x Playing Sounds Paulo de Arruda Borelli Excel Programming 1 August 11th 03 07:51 PM


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