Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Are Sounds Supported?

Sounds supported
0
Posted

Are Sounds Supported?

0

Not all systems support sound. If you need to determine if sounds are supported, use the CanPlaySounds method. Here’s an example: If Not Application.CanPlaySounds Then MsgBox “Sorry, sound is not supported on your system.” Exit Sub End If Example: Playing a WAV File The example below contains the API function declaration, plus a simple subroutine to play a sound file called dogbark.wav, which is assumed to be in the same directory as the workbook. Private Declare Function PlaySound Lib “winmm.dll” _ Alias “PlaySoundA” (ByVal lpszName As String, _ ByVal hModule As Long, ByVal dwFlags As Long) As Long Const SND_SYNC = &H0 Const SND_ASYNC = &H1 Const SND_FILENAME = &H20000 Sub PlayWAV() WAVFile = “dogbark.wav” WAVFile = ThisWorkbook.Path & “\” & WAVFile Call PlaySound(WAVFile, 0&, SND_ASYNC Or SND_FILENAME) End Sub In the example above, the WAV file is played asynchronously. This means execution continues while the sound is playing. If you would like code execution to stop while the sound

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123