hello,
Patrick avec un close all cela devrait mieux fonctionner. Comme ceci par exemple :
==============================================
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 Private Declare PtrSafe Function mciSendString Lib "winmm.dll" Alias _ "mciSendStringA" (ByVal lpstrCommand As String, ByVal _ lpstrReturnString As Any, ByVal uReturnLength As Long, ByVal _ hwndCallback As Long) As Long Private Declare Function fGetShortPathName Lib "kernel32" Alias _ "GetShortPathNameA" (ByVal lpszLongPath As String, ByVal _ lpszShortPath As String, ByVal cchBuffer As Long) As Long Function GetShortPathName(sLongPathName As String) As String Dim lLen As Long Dim sShortPathname As String If Dir(sLongPathName, vbDirectory) = "" Then Exit Function sShortPathname = Space$(260) lLen = fGetShortPathName(sLongPathName, sShortPathname, 260) 'If (lLen = 0) Then Exit Function 'Not needed since DIR was used. GetShortPathName = sShortPathname End Function
Ami calmant, J.P
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 Sub PlayMP3() Dim AudioFile As String Dim MciError As Long AudioFile = GetShortPathName(ActiveCell.Text) MciError = mciSendString("play " & AudioFile, 0&, 0, 0) If MciError <> 0 Then MsgBox ("Erreur MCI : " & MciError) End If End Sub Sub ArretMP3() Dim AudioFile As String Dim MciError As Long AudioFile = GetShortPathName(ActiveCell.Text) MciError = mciSendString("close all", 0&, 0, 0) If MciError <> 0 Then MsgBox ("Erreur MCI : " & MciError) End If End Sub Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.Column = 1 Then If Target <> "" Then ArretMP3 PlayMP3 Else ArretMP3 End If End If End Sub
Partager