Vous utilisez un navigateur obsolète. Il se peut que ce site ou d'autres sites Web ne s'affichent pas correctement. Vous devez le mettre à jour ou utiliser un navigateur alternatif.
Boostez vos compétences Excel avec notre communauté !
Rejoignez Excel Downloads, le rendez-vous des passionnés où l'entraide fait la force.
Apprenez, échangez, progressez – et tout ça gratuitement !
👉 Inscrivez-vous maintenant !
Private Declare PtrSafe Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As LongPtr, ByVal dwFlags As Long) As Long
'https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-messagebeep
Private Declare PtrSafe Function MessageBeep& Lib "user32.dll" (ByVal dwFlags As Long)
Sub a()
PlaySound "C:\Windows\Media\Windows Critical Stop.wav", ByVal 0&, &H20001
End Sub
Sub b()
MessageBeep &HFFFFFFFF
'MessageBeep vbOK
'MessageBeep vbError
'MessageBeep vbCritical
'MessageBeep vbExclamation
'MessageBeep vbInformation
End Sub
Sub d()
Beep
End Sub
bonsoir
et bien d'autres possibilités encore
par exemple faire son propre beep composé
VB:
Declare PtrSafe Function ApiBeep Lib "kernel32" Alias "Beep" (ByVal dwFreq As Long, ByVal dwDuration As Long) As Long
Sub jouerbeepperso() 'joue 4 notes differentes d'une durée de 50 millisecondes
ApiBeep 1000, 50: ApiBeep 800, 50: ApiBeep 500, 50: ApiBeep 200, 50
End Sub
ou bien jouer un des son window avec sapi.voice
Code:
Sub joueSonWindowSapiVoice()
Const wavFile = "C:\Windows\Media\Windows Exclamation.wav"
Dim oVoice: Set oVoice = CreateObject("SAPI.SpVoice")
Dim oSpFileStream: Set oSpFileStream = CreateObject("SAPI.SpFileStream")
oSpFileStream.Open wavFile
oVoice.SpeakStream oSpFileStream
oSpFileStream.Close
End Sub
Private Declare PtrSafe Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As LongPtr, ByVal dwFlags As Long) As Long
'https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-messagebeep
Private Declare PtrSafe Function MessageBeep& Lib "user32.dll" (ByVal dwFlags As Long)
Sub a()
PlaySound "C:\Windows\Media\Windows Critical Stop.wav", ByVal 0&, &H20001
End Sub
Sub b()
MessageBeep &HFFFFFFFF
'MessageBeep vbOK
'MessageBeep vbError
'MessageBeep vbCritical
'MessageBeep vbExclamation
'MessageBeep vbInformation
End Sub
Sub d()
Beep
End Sub
- Navigue sans publicité - Accède à Cléa, notre assistante IA experte Excel... et pas que... - Profite de fonctionnalités exclusives Ton soutien permet à Excel Downloads de rester 100% gratuit et de continuer à rassembler les passionnés d'Excel. Je deviens Supporter XLD