YasserKhalil
Well-known Member
- Joined
- Jun 24, 2010
- Messages
- 852
I am working on a code that would play MP3 files from a specific directory based on a list of the file names of these mp3 files in column A. The code works fine for about five or six files then excel hangs for some time then resume from another unexpected point. How can I fix the code so as to make it play all the mp3 files in column A?
I got an answer from this link
Play MP3 files using loops
but this stores all the files then play them all .. I need to set waiting time between each file and at the same time I need to select the cell that is playing ..
VBA Code:
Public wmp As Object
Sub Test()
Dim r As Long
Set wmp = CreateObject("new:6BF52A52-394A-11D3-B153-00C04F79FAA6")
For r = 1 To Cells(Rows.Count, 1).End(xlUp).Row
With wmp
.URL = ThisWorkbook.Path & "\Media\" & Cells(r, 1).Value & ".mp3"
.Controls.Play
End With
DoEvents
Application.Wait Now + TimeValue("00:00:02")
Next r
End Sub
I got an answer from this link
Play MP3 files using loops
but this stores all the files then play them all .. I need to set waiting time between each file and at the same time I need to select the cell that is playing ..