I have the following code that is put in worksheet module and reference to wmp.dll (Windows Media Player)
The code is fine as it lets me to set pauses between each mp3 file wen running it
Code: Select all
Private WithEvents wmp As WindowsMediaPlayer
Private r As Range
Sub StartPlaying()
Set wmp = CreateObject("new:6BF52A52-394A-11D3-B153-00C04F79FAA6")
Set r = [A1]
PauseAndPlay 0
End Sub
Private Sub wmp_PlayStateChange(ByVal NewState As Long)
If NewState = 1 Then Application.OnTime Now, CodeName & ".PauseAndPlay"
End Sub
Public Sub PauseAndPlay(Optional PauseSecs As Integer = 2)
If r Is Nothing Then Exit Sub: If Len(r) = 0 Then Exit Sub
Application.Wait Now + TimeSerial(0, 0, PauseSecs)
wmp.URL = ThisWorkbook.Path & "\" & Split(ThisWorkbook.Name, ".")(0) & "\" & r & ".mp3"
Application.Goto r, True
wmp.Controls.Play
Set r = r.Offset(1)
End Sub