#If VBA7 Then
Private Declare PtrSafe Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" ( _
ByVal lpstrCommand As String, _
ByVal lpstrReturnString As String, _
ByVal uReturnLength As Long, _
ByVal hwndCallback As LongPtr) As Long
#Else
Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" ( _
ByVal lpstrCommand As String, _
ByVal lpstrReturnString As String, _
ByVal uReturnLength As Long, _
ByVal hwndCallback As Long) As Long
#End If
Sub PlayMP3(filePath As String)
Dim command As String
command = "open """ & filePath & """ type mpegvideo alias mp3"
mciSendString command, vbNullString, 0, 0
mciSendString "play mp3", vbNullString, 0, 0
End Sub
Sub StopMP3()
mciSendString "close mp3", vbNullString, 0, 0
End Sub
Private Sub TestMP3()
Dim filePath As String
filePath = "D:\Desktop\NhacXoSo-VA-4512353.mp3" ' Replace with the actual path to your MP3 file
PlayMP3 filePath
End Sub