Friday, April 22, 2016

Playing A Sound Based On A Cell’s Value

              The created macro plays a sound according to value of changed cell in Column C.

New value can be entered to cells in Column C with combobox. In this macro, we have used 3 different sound (chimes.wav ,chord.wav ,tada.wav)


Wednesday, April 20, 2016

Sound Alert In Excel

Playing A Sound File If A Condition Is Met

        The created macro plays a .wav file (C:\Windows\Media\chord.wav) when a duplicate value is entered in Column A. 
Later a msgbox is opened and the msgbox  shows repeated values' row numbers.
Our code to play .wav file :

#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


Sunday, April 17, 2016

Playing The Sounds In Excel


          In this example ,we have played the sounds in directory with macros that we assigned to shapes .For this process we have used ExecuteExcel4Macro Method. For example :

Application.ExecuteExcel4Macro "SOUND.PLAY(,""" & ActiveWorkbook.Path & "\mi.wav"")"


In the example on second page, we have used Function sndPlaySound32 to play the sounds.  For example :

Declare Function sndPlaySound32 Lib "winmm.dll" Alias "sndPlaySoundA" ( _
ByVal lpszSoundName As String, ByVal uFlags As Long) As Long

Sub Do_2()
    Call sndPlaySound32(ThisWorkbook.Path & "\do.wav", 0)
End Sub


Sunday, April 10, 2016

Access Database Management With Excel Userform

Access Database Example          

         We created personnel database in Access. Later we created connection from Excel Userform to Access Database .

With this userform ;

- New data can be added to Access Database
- Data can be changed
- Data can be deleted
- Data can be searched in Access Database
- Data can be transferred from the Access Database to Excel.