Home > Excel Tutorial > Playing A Sound File If A Condition Is Met

Playing A Sound File If A Condition Is Met

Excel Sound Alert

This macro plays a .wav file (C:\Windows\Media\chord.wav) when a duplicate value is entered in Column A.
Also msgbox is opened and the msgbox  shows repeated values’ row numbers.Used code to play the sound :

#If Win64 Then

‘Code is running in 64-bit Office

Private Declare PtrSafe Function sndPlaySound Lib “winmm.dll” Alias “sndPlaySoundA” ( _

ByVal lpszSoundName As String, _

ByVal uFlags As Long) As Long

#Else

‘Code is running in 32-bit Office

Private Declare Function sndPlaySound32 Lib “winmm.dll” Alias “sndPlaySoundA” ( _

ByVal lpszSoundName As String, _

ByVal uFlags As Long) As Long

#End If

….

 #If Win64 Then

sndPlaySound “C:\Windows\Media\chord.wav”, 0&

#Else

sndPlaySound32 “C:\Windows\Media\chord.wav”, 0&

#End If

excel sound alert , play sound

Download example file

  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: