Hi team,
I am working on a VBA code that sound an alarm, but of course I would like the code to make sure that the sound is turned on (and not too loud). Any one that can help me?
/Casper
Hi team,
I am working on a VBA code that sound an alarm, but of course I would like the code to make sure that the sound is turned on (and not too loud). Any one that can help me?
/Casper
Please click the * Add Reputation if this helps
If solved remember to mark Thread as solved
"I'm glad to help and this is not meant to sound smart, but either you have super-human vision to see all those controls cleared one by one with the code I posted, or your computer is really slow."
Not quite what you are after but possibly a start. Not sure how you determine the current volume level and therefore if the volume needs to go up or down? You need to loop the up or down calls several times to simulate key presses.
![]()
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long) Const VK_VOLUME_MUTE = &HAD 'Windows 2000/XP: Volume Mute key Const VK_VOLUME_DOWN = &HAE 'Windows 2000/XP: Volume Down key Const VK_VOLUME_UP = &HAF 'Windows 2000/XP: Volume Up key Sub VolUp() '-- Turn volumn up -- keybd_event VK_VOLUME_UP, 0, 1, 0 keybd_event VK_VOLUME_UP, 0, 3, 0 End Sub Sub VolDown() '-- Turn volumn down -- keybd_event VK_VOLUME_DOWN, 0, 1, 0 keybd_event VK_VOLUME_DOWN, 0, 3, 0 End Sub Sub VolToggle() '-- Toggle mute on / off -- keybd_event VK_VOLUME_MUTE, 0, 1, 0 End Sub
Please consider adding a * if I helped.
Possibly of interest..............
http://support.microsoft.com/kb/118377
Thanks a lot. At least now I can toggle on/off. I guess my only problem is, that I don't know whether the sound is on or off when the macro runs, but I believe I saw how to read that somewhere else in here.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks