View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
keepITcool keepITcool is offline
external usenet poster
 
Posts: 2,253
Default API commands to turn volume control on



Reading the current state of the 'Master Mute' checkbox
is a trifle complicated :( see Harald's link..

But in addition to Bob's solution of shelling to SndVol..
If you're working in Win2k/XP then Mute Toggling and VolumeUp and Down
can easily be done via the keyboard..

Option Explicit

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

Private Declare Sub keybd_event Lib "user32" ( _
ByVal bVk As Byte, ByVal bScan As Byte, _
ByVal dwFlags As Long, ByVal dwExtraInfo As Long)


Sub VolUp()
keybd_event VK_VOLUME_UP, 0, 1, 0
keybd_event VK_VOLUME_UP, 0, 3, 0
End Sub
Sub VolDown()
keybd_event VK_VOLUME_DOWN, 0, 1, 0
keybd_event VK_VOLUME_DOWN, 0, 3, 0
End Sub

Sub VolToggle()
keybd_event VK_VOLUME_MUTE, 0, 1, 0
End Sub







--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Mike wrote :

Thanks in advance for your help.

Does anyone have some VBA code that will unmute the sound
for the Windows Volume control using Excel?

I read some stuff in Walkenbach's book about displaying
stuff from the Control Panel within Excel using windows
API calls but I didn't see anything about changing the
volume settings. Thanks again.