Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default How to Mute/Enable Windows Sounds whilst running VBA code

Most of the time, my PC runs silently. I am easily irritated by sounds of
windows opening, etc. etc. But exceptionally, I would like to be advised of
an unusual event by playing a Wav file through code. Is there a pair of
lines that I can add to enable before, and mute after the required sound has
played? Here is an example:

Private Declare Function PlaySound Lib "winmm.dll" _
Alias "PlaySoundA" (ByVal lpszName As String, _
ByVal hModule As Long, ByVal dwFlags As Long) As Long


Public Sub PrinterCheck()

Dim int1as integer
Dim strWavFile As String

int1 = MsgBox("Ready to Print?", vbYesNoCancel)
boolNP = True
If int1 = 6 Then
strWavFile = ThisWorkbook.Path & "\sound1.wav"
boolNP = False
ElseIf int1 = 7 Then
strWavFile = ThisWorkbook.Path & "\sound2.wav"
End If
Call PlaySound(strWavFile, 0&, SND_ASYNC Or SND_FILENAME)

End Sub


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Running Excel 2003 on Windows 7 PT[_3_] New Users to Excel 1 December 15th 09 09:02 AM
Running a macro from windows application Aerojade Excel Discussion (Misc queries) 1 October 3rd 08 01:19 PM
i have two windows xp running on my pc and seem to con flict with custer Excel Discussion (Misc queries) 1 November 21st 05 09:30 PM
Status bar (or similar) to appear whilst running a long macro Ant Excel Discussion (Misc queries) 8 November 11th 05 09:21 AM
running windows system commands in VBA tomek Excel Programming 1 February 5th 04 12:36 PM


All times are GMT +1. The time now is 01:45 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"