DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

Author Topic: Silent msgbox() popup in VBA for Word  (Read 8,388 times)

hgondalf

  • Participant
  • Joined in 2010
  • *
  • Posts: 15
Silent msgbox() popup in VBA for Word
« on: May 06, 2010, 02:08 PM »
I write lots of VBA applications in the course of my work.  Often I use a msgbox() function, with buttons Yes, No, Cancel, to get a 3-way selection, e.g.,

Select case msgbox("Are you Hot (yes), Cold (no), or Lukewarm (cancel)", VBYesNoCancel)
  case vbyes :  <some code>
  case vbno :  <some code>
  case vbcancel :  <some code>
end select

Trouble is, looping through a long document causes the message box to pop up dozens of times, severely annoying my co-workers and driving me crazy. 

I know I can turn off the notification sound in the Control Panel.  How about writing a little app that could be called from VBA, that would turn on/turn off the sound?  My VBA code would then look like this:

  x = shell ("c:\utils\soundoff.exe off")
  < a little timer delay >
  messgebox ( ) parsing
  x = shell ("c:\utils\soundoff.exe on")

The shell function in VBA returns a value, 0 if no problem, or the program ID otherwise, which is why I have the dummy parameter variable x. 

One can set/reset the sounds in the registry, but I wonder if it is tempting fate to write/rewrite the registry...

How about simply muting the speakers for a moment while the messgebox come up?

BTW I'm running Windows XP HE, but I have Vista and 98 also.

Thanks! 
« Last Edit: May 06, 2010, 02:57 PM by hgondalf »

AbteriX

  • Member #520
  • Charter Honorary Member
  • Joined in 2005
  • ***
  • Posts: 1,150
Re: Silent msgbox() popup in VBA for Word
« Reply #1 on: May 06, 2010, 08:23 PM »
One can set/reset the sounds in the registry, but I wonder if it is tempting fate to write/rewrite the registry...
What do you think how those other tools would do this?


   x = shell ("c:\utils\soundoff.exe off")
If you want an external tool you can try something like NirSoft NirCMD

http://www.nirsoft.net/utils/nircmd.html

* freeware
* stand alone/portable

Examples:
Mute the system volume nircmd.exe mutesysvolume 1
Unmute the system volume nircmd.exe mutesysvolume 0
Switch the system volume between the mute and normal state. nircmd.exe mutesysvolume 2
Greetings, Stefan.

Original address: https://www.donationcoder.com/forum/index.php?topic=22652.0