Create A Piano With Codes In Excel

February 18, 2017 Leave a comment

In the example, we have used function sndPlaySound32 to play musical (the piano) notes.
Musical notes can be played through buttons on the worksheet and function keys of keyboard – function keys (F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F12) are assigned   to run macros that are created to play music notes -.

The used codes to assign:

Sub A_1()
Call sndPlaySound32(ThisWorkbook.Path & “\a1.wav”, 0)
End Sub
Sub B_1()
Call sndPlaySound32(ThisWorkbook.Path & “\b1.wav”, 0)
End Sub
Sub C_1()
Call sndPlaySound32(ThisWorkbook.Path & “\c1.wav”, 0)
End Sub
Sub D_1()
Call sndPlaySound32(ThisWorkbook.Path & “\d1.wav”, 0)
End Sub
Sub E_1()
Call sndPlaySound32(ThisWorkbook.Path & “\e1.wav”, 0)
End Sub

Sub auto_open()
Application.OnKey “{F1}”, “A_1”
Application.OnKey “{F2}”, “B_1”
Application.OnKey “{F3}”, “C_1”
Application.OnKey “{F4}”, “D_1”
Application.OnKey “{F5}”, “E_1”

End Sub

excel play sound

Download Example File

 

Excel Sound Alerts Based On Cell Value

February 16, 2017 Leave a comment