View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default Using Countdown in Status Bar to Play Sound

Here's the full monty (sorry, couldn't avoid it)

Option Explicit

Const SND_SYNC = &H0
Const SND_ASYNC = &H1
Const SND_FILENAME = &H20000

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

Sub CountDown()
Dim intCounter As Integer
Dim bln As Boolean
bln = Application.DisplayStatusBar
Application.DisplayStatusBar = True
For intCounter = 180 To 1 Step -1
If intCounter = 30 Or intCounter = 10 Then
PlayWAVFile "C:\Windows\Media\chimes.wav"
End If
Application.StatusBar = intCounter & " Seconds..."
Application.Wait Now + TimeSerial(0, 0, 1)
Next
PlayWAVFile "C:\Windows\Media\tada.wav"
Application.StatusBar = False
Application.DisplayStatusBar = bln
End Sub

Sub PlayWAVFile(Filename As String, Optional Async As Boolean = True)
If Async Then
Call PlaySound(Filename, 0&, SND_ASYNC Or SND_FILENAME)
Else
Call PlaySound(Filename, 0&, SND_SYNC Or SND_FILENAME)
End If
End Sub

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Full Monty " wrote in message
...
Thanks for the response guys! Again since I am fairly new to VBA code, I
am having trouble understanding where you want me to insert it.

The Countdown code I am currently using is:
Sub CountDown()
Dim intCounter As Integer
Dim bln As Boolean
bln = Application.DisplayStatusBar
Application.DisplayStatusBar = True
For intCounter = 180 To 1 Step -1
Application.StatusBar = intCounter & " Seconds..."
Application.Wait Now + TimeSerial(0, 0, 1)
Next intCounter
Application.StatusBar = False
Application.DisplayStatusBar = bln
End Sub

Do I insert the code you guys posted somewhere inside this code? In the
same module but separate section? Or in a new module?

I have all three WAV files located in a folder called "My Folder" in C:
drive. Pathway is C:\My Folder\Sound 1" and so on.

Again thanks for all the help! I am learning alot!


---
Message posted from http://www.ExcelForum.com/