Callings Windows Default Sounds in a Macro

dusty9

New Member
Joined
Oct 2, 2014
Messages
15
Office Version
  1. 2016
Platform
  1. Windows
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'?
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
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.
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,752
Members
448,989
Latest member
mariah3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top