ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Playing music (https://www.excelbanter.com/excel-programming/305018-playing-music.html)

Naveen Sukhramani

Playing music
 
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

Bob Phillips[_6_]

Playing music
 
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)

"Naveen Sukhramani" wrote in message
om...
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




Don Guillett[_4_]

Playing music
 
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


--
Don Guillett
SalesAid Software

"Naveen Sukhramani" wrote in message
om...
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





All times are GMT +1. The time now is 07:12 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com