Bonjour à tous.

Avec Windows 10 et VBA Excel 365, lorsque j'utilise un fichier audio, c'est Groove Musique qui se lance.

Comment faire pour qu'il se ferme automatiquement après avoir jouer le son ?

Voici le code que nous utilisons :

Code vba : 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
 
Function message_sonore(fichier_wav)
If DOSSIER_SPEECH = "" Then
        DOSSIER_SPEECH = "J:\exe\scripts_conversion_vista\requeteurs_excel\speech"
End If
Application.ScreenUpdating = False
If GLOB_LAST_FICHIER_WAV <> fichier_wav Then
    fichier_txt = DOSSIER_SPEECH & fichier_wav
    If recherche_si_dossier_hd_existe(DOSSIER_SPEECH) = "OK" Then
            If recherche_si_fichier_existe(fichier_txt, False) <> "PB" Then
                    'ShellWait "C:\bin_exe_sai\sndrec32.exe /play /Close " & fichier_txt
                    'sndPlaySound32 fichier_txt, 0&    ' Finally, play the sound.
                    mciExecute ("play " & fichier_txt & " wait")
                    myWait_v1 (1)
            Else
                    'ShellWait "C:\bin_exe_sai\sndrec32.exe /play /Close " & DOSSIER_SPEECH & "\" & "message_sonore_inexistant.wav"
                    'sndPlaySound32 DOSSIER_SPEECH & "\" & "message_sonore_inexistant.wav", 0&    ' Finally, play the sound.
                    mciExecute ("play " & DOSSIER_SPEECH & "\" & "message_sonore_inexistant.wav" & " wait")
                    'Call maj_feuille_log("PB ", "PAS_TROUVE " & fichier_wav)
            End If
    End If
End If
GLOB_LAST_FICHIER_WAV = fichier_wav
End Function

Merci d'avance, les gars.