LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming
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/





 
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
play sound when closing xcel 2007 Pirgnori Excel Discussion (Misc queries) 1 December 28th 09 09:21 PM
Play sound aac Excel Discussion (Misc queries) 2 December 5th 07 11:24 PM
Play Sound File Once when cell value condition id met John 1 Excel Discussion (Misc queries) 4 September 1st 07 04:32 PM
play sound when pressing commandbutton Hoyos Excel Discussion (Misc queries) 1 August 19th 07 04:12 PM
Can you auto-trigger a sound file to play when a worksheet opens? Nanotexan Excel Worksheet Functions 1 February 5th 06 05:16 PM


All times are GMT +1. The time now is 01:20 PM.

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"