Callings Windows Default Sounds in a Macro

dusty9

New Member
Joined
Oct 2, 2014
Messages
11
Hello,
I'm trying to add sounds to my worksheet and instead of getting it to play sounds through a media player, I'm modifying a windows default sound scheme and playing them through that. I have seen that putting 'beep' in a macro calls the sound I have for 'default beep' in the sound scheme, I'm just wondering where I find the names that vba recognizes for the sounds that are default for a computer. For example if I put a sound in for 'close program' or 'minimize' in the sound scheme, what would I type in the code to call that? Just 'close' or 'minimize'?
 

Some videos you may like

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)

John_w

MrExcel MVP
Joined
Oct 15, 2007
Messages
6,416
Code:
Private Declare Function sndPlaySound32 Lib "winmm.dll" Alias "sndPlaySoundA" _
    (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long

Sub test()
    sndPlaySound32 "C:\Windows\Media\tada.wav", &H1
    Application.Wait DateAdd("s", 2, Now)
    sndPlaySound32 "C:\Windows\Media\ding.wav", &H1
End Sub
You'll need to change the sndPlaySound32 declaration for 64-bit Windows.
 

Watch MrExcel Video

Forum statistics

Threads
1,108,814
Messages
5,525,047
Members
409,616
Latest member
ULFireTester

This Week's Hot Topics

Top