Playing music

N

Naveen Sukhramani

Is there a way to write a code in an excel file that will enable me to
play some music (on windows media player etc) and after the piece is
played, return me back to excel?

Thanks,

Naveen
 
B

Bob Phillips

Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" _
(ByVal lpszName As String, _
hModule As Long, _
ByVal dwFlags As Long) As Long

'-----------------------------------------------------------------
Public Function PlayWavFile(WavFile As String) As String
'-----------------------------------------------------------------
Const SND_ASYNC = &H1
Const SND_FILENAME = &H20000
PlaySound WavFile, 0, SND_ASYNC Or SND_FILENAME
PlayWavFile = ""
End Function


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
D

Don Guillett

Here is one I use in a double_click event to play the highlighted title
where the full file name is in col E and I am clicking any column. Also,
look at the other one

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
If Target.Row = 4 Then
Range("a5:g" & Range("a65536").End(xlUp).Row) _
..Sort Key1:=Cells(5, ActiveCell.Column), Order1:=xlAscending,
Orientation:=xlTopToBottom
Cells(5, Target.Column).Select
End If
mc = Cells(ActiveCell.Row, "e")
If Target.Row > 4 Then
x = Right(Application.OperatingSystem, 4)
If x < 5 Then
cmd = "Start " & Chr(34) & mc & Chr(34)
Shell cmd 'works with xl97
Else
Dim FullFileName As String
FullFileName = mc
ActiveWorkbook.FollowHyperlink Address:=FullFileName
End If
End If
End Sub
======
This might be easier for you.

Sub playselections()
For Each C In Selection
mc = Cells(C.Row, "e")
x = Right(Application.OperatingSystem, 4)
If x < 5 Then
cmd = "Start " & Chr(34) & mc & Chr(34)
Shell cmd 'works with xl97
Else
Dim FullFileName As String
FullFileName = mc
ActiveWorkbook.FollowHyperlink Address:=FullFileName
End If
Next
End Sub
 
Top