+ Reply to Thread
Results 1 to 5 of 5

Turn on sound using VBA

Hybrid View

cguldmann Turn on sound using VBA 01-23-2015, 08:04 PM
Blokeman Re: Turn on sound using VBA 01-23-2015, 08:18 PM
Brendan_Floyde Re: Turn on sound using VBA 01-23-2015, 08:19 PM
Brendan_Floyde Re: Turn on sound using VBA 01-24-2015, 03:37 AM
cguldmann Re: Turn on sound using VBA 01-24-2015, 03:52 PM
  1. #1
    Registered User
    Join Date
    01-23-2015
    Location
    Denmark
    MS-Off Ver
    W8
    Posts
    2

    Turn on sound using VBA

    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

  2. #2
    Forum Contributor
    Join Date
    08-15-2012
    Location
    Australia
    MS-Off Ver
    Excel 2016
    Posts
    349

    Re: Turn on sound using VBA

    Read this;http://www.mrexcel.com/forum/excel-q...er-volume.html
    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."

  3. #3
    Forum Contributor
    Join Date
    01-14-2014
    Location
    London, England
    MS-Off Ver
    Excel 2013
    Posts
    240

    Re: Turn on sound using VBA

    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.

  4. #4
    Forum Contributor
    Join Date
    01-14-2014
    Location
    London, England
    MS-Off Ver
    Excel 2013
    Posts
    240

    Re: Turn on sound using VBA

    Possibly of interest..............

    http://support.microsoft.com/kb/118377

  5. #5
    Registered User
    Join Date
    01-23-2015
    Location
    Denmark
    MS-Off Ver
    W8
    Posts
    2

    Re: Turn on sound using VBA

    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.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Turn off calculations before query refresh....turn them back on after
    By mk3ll00 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-30-2014, 03:25 PM
  2. Auto calc on, then turn off, then runtime error how to turn back on
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 11-22-2011, 10:37 AM
  3. Replies: 1
    Last Post: 07-30-2010, 03:35 PM
  4. sound
    By pytelium in forum Excel General
    Replies: 3
    Last Post: 07-24-2005, 05:41 PM
  5. Sound in a cell?
    By Tom Slypaw in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 01-23-2005, 08:09 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1