Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Detecting the actual playing or NOT playing of a WAV file | Excel Discussion (Misc queries) | |||
Using Multiple Tests and Sounds With Worksheet Macros | Excel Discussion (Misc queries) | |||
Macros for playing sounds | Excel Discussion (Misc queries) | |||
playing sounds from cell value | Excel Programming | |||
Excel XP x Playing Sounds | Excel Programming |