Hello everyone!
Well, let's say that I've just arrived to this VBA excel world. One week ago I have no idea that microsoft excel had such a cool feature...
Somehow I've managed (thx google!) to insert an extremely helpful VBA code on one of my excel files.
I'm using Microsoft Excel 2010 on Windows 7 64 bits.
This code looks on 2 different columns, and plays a .wav file based on the cell value.
It works perfect, no issues at all. But I'm looking to create also a clickeable button, that plays the .wav file based on the cell selected.
So if for example the cell contains the value "ladygaga", when you click the button it plays the audio ladygaga.wav.
Any help with this would be really much appreciated
Thx in advance!
Well, let's say that I've just arrived to this VBA excel world. One week ago I have no idea that microsoft excel had such a cool feature...
Somehow I've managed (thx google!) to insert an extremely helpful VBA code on one of my excel files.
I'm using Microsoft Excel 2010 on Windows 7 64 bits.
This code looks on 2 different columns, and plays a .wav file based on the cell value.
Code:
Private Declare PtrSafe 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
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Cancel = True
On Error Resume Next
If Target.Column = 1 Then
Call PlaySound("C:\Users\Diego\Desktop\" & Target.Value & ".wav", 0&, SND_ASYNC Or SND_FILENAME)
Else
Call PlaySound("D:\" & Target.Value & ".wav", 0&, SND_ASYNC Or SND_FILENAME)
End If
On Error GoTo 0
End Sub
So if for example the cell contains the value "ladygaga", when you click the button it plays the audio ladygaga.wav.
Any help with this would be really much appreciated
Thx in advance!