View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Chip Pearson Chip Pearson is offline
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.