vba to increase speaker volume

pujo

Well-known Member
Joined
Feb 19, 2009
Messages
708
Office Version
  1. 2019
  2. 2013
Platform
  1. Windows
Hey gang,
Just wondering if anyone has ever ran across any vba that will turn on the speaker volume, and set the level to max?

Thanks,
PuJo
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
A partial answer:

Code:
Option Explicit

'Mostly from
'http://www.mrexcel.com/forum/showthread.php?p=2291517
'http://www.pcreview.co.uk/forums/api-commands-turn-volume-control-t1008148.html
'http://support.microsoft.com/default.aspx?scid=kb;en-us;178456

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

The second link contains (long) code to determine the state of the mute button rather than just toggling it.
 
Upvote 0
Thanks,
This is a great starting point for my project, (prank!)

PuJo

Happy Holidays!
 
Upvote 0
Thanks Phil,
I am feeling a little devious right now!
:oops::biggrin::oops:
 
Upvote 0
:rolleyes:

Waw... it is realy helpful. but i have one question regarding same script.

:rolleyes:
May i know how to do this same in .vbs file? Please help to get resolve this. It is very helpful for me.
I am searching answer from last 26 days. :(
 
Upvote 0
The thread is three years old, but more importantly, you won't find many VBS experts here. It would be better to try a VBS list instead of and Excel list.
 
Upvote 0
The thread is three years old, but more importantly, you won't find many VBS experts here. It would be better to try a VBS list instead of and Excel list.
The main thread is three years old, as you mentioned, but you told that to someone who posted their question over six months ago.:eek:
 
Upvote 0

Forum statistics

Threads
1,214,990
Messages
6,122,626
Members
449,094
Latest member
bsb1122

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top