Is it possible to make a sound if the msgbox appears?
Private Sub Worksheet_Change(ByVal Target As Range)
If [ge141] <> [ge142] Then
MsgBox "Deze invoer is onjuist"
End If
End Sub
Ger
Is it possible to make a sound if the msgbox appears?
Private Sub Worksheet_Change(ByVal Target As Range)
If [ge141] <> [ge142] Then
MsgBox "Deze invoer is onjuist"
End If
End Sub
Ger
You could use [VBA]MsgBox "Deze invoer is onjuist",vbCritical[/VBA]I believe it uses the sounds that are declared within your windows OS.
Charlize
Sorry, no sound.
Ger
try beep
eg
[vba]sub msgbeep()
msgbox "blah blah blah",vbokonly
beep
end sub
[/vba]
Always Mark your Thread as Solved the moment u got acceptable reply (located under Thread tools)
Practice this & save time of others in thinking for unsolved thread
Variation with the music you want. You can record your own wav files if you want.[VBA]Option Explicit
Declare Function sndPlaySound32 Lib "winmm.dll" Alias "sndPlaySoundA" _
(ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
Sub PlaySound()
Dim v_mysound As String
v_mysound = "c:\data\mysounds\tada.wav"
If Application.CanPlaySounds Then
Call sndPlaySound32(v_mysound, 1)
MsgBox "Give me some music ..."
Else
MsgBox "Sorry no music"
End If
End Sub[/VBA]Charlize
I think it doens't work because i use it on a worksheet and not on a module.
Ger
It is not that, it works fine triggered by the change event. Sure you don't have sound muted?
____________________________________________
Nihil simul inventum est et perfectum
Abusus non tollit usum
Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
James Thurber
[vba]Private Sub Worksheet_Change(ByVal Target As Range)Originally Posted by Ger
If [ge141] <> [ge142] Then
Call PlaySound
End If
End Sub[/vba]and PlaySound is located in a module.
Charlize
ps.: maybe check your cables, muted or not, volume, ... do you have a soundcard ?
variation :
[VBA]Private Sub Worksheet_Change(ByVal Target As Range)
If [ge141] <> [ge142] Then
Call PlaySound("c:\data\mysounds\tada.wav")
End If
End Sub[/VBA]
in a module you place :[VBA]Declare Function sndPlaySound32 Lib "winmm.dll" Alias "sndPlaySoundA" _
(ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
Sub PlaySound(v_mysound As String)
If Application.CanPlaySounds Then
Call sndPlaySound32(v_mysound, 1)
MsgBox "Give me some music ..."
Else
MsgBox "Sorry no music"
End If
End Sub[/VBA]
Ok.
Now it works fine.
Thanks
So what was the problem?
____________________________________________
Nihil simul inventum est et perfectum
Abusus non tollit usum
Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
James Thurber
The path to the sound file in the worksheet didn't work. if i put it in the module it works fine.
(worksheet)
Private Sub Worksheet_Change(ByVal Target As Range)
If [ge119] <> [ge120] Then
Call PlaySound
End If
End Sub
(module)
Option Explicit
Declare Function sndPlaySound32 Lib "winmm.dll" Alias "sndPlaySoundA" _
(ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
Sub PlaySound()
Dim v_mysound As String
v_mysound = "j:\zuid\zml\vpm\jaarplanner vpm\52.wav"
If Application.CanPlaySounds Then
Call sndPlaySound32(v_mysound, 1)
MsgBox "Deze invoer is niet correct"
Else
MsgBox "Sorry no music"
End If
End Sub
Ger