Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default calling sounds in VBA for Excel2003

Based on what I can glean from other threads, it seems that I could not call
the tada.wav using VBA code in Excel 2003. If this is not true, what is the
code. I have tried the XL2000 code and it did not work. Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default calling sounds in VBA for Excel2003

You can give this a try...

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

Private Declare Function Beep Lib "kernel32" (ByVal dwFreq As Long, ByVal
dwDuration _
As Long) As Long

Public Sub PlayMe()
PlayWavFile "C:\Windows\Media\Microsoft Office 2000\Chimes.wav"
End Sub

Public Function PlayWavFile(WavFile As String) As String
Const SND_ASYNC = &H1
Const SND_FILENAME = &H20000
PlaySound WavFile, 0, SND_ASYNC Or SND_FILENAME
PlayWavFile = ""
End Function
--
HTH...

Jim Thomlinson


"JLGWhiz" wrote:

Based on what I can glean from other threads, it seems that I could not call
the tada.wav using VBA code in Excel 2003. If this is not true, what is the
code. I have tried the XL2000 code and it did not work. Thanks.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default calling sounds in VBA for Excel2003

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 PlayWAVFile(Optional Async As Boolean = True)
Dim WavFile As String
WavFile = "tada.wav"
WavFile = "C:\Windows\Media\" & WavFile
If Async Then
Call PlaySound(WavFile, 0&, SND_ASYNC Or SND_FILENAME)
Else
Call PlaySound(WavFile, 0&, SND_SYNC Or SND_FILENAME)
End If
End Sub


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"JLGWhiz" wrote in message
...
Based on what I can glean from other threads, it seems that I could not

call
the tada.wav using VBA code in Excel 2003. If this is not true, what is

the
code. I have tried the XL2000 code and it did not work. Thanks.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default calling sounds in VBA for Excel2003

Thanks to both of you guys for the response. Here is the code that worked.

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

Public Sub PlayMe()
PlayWavFile "C:\Windows\Media\tada.wav"
End Sub

Public Function PlayWavFile(WavFile As String) As String
Const SND_ASYNC = &H1
Const SND_FILENAME = &H20000
PlaySound WavFile, 0, SND_ASYNC Or SND_FILENAME
PlayWavFile = ""
End Function


"Bob Phillips" wrote:

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 PlayWAVFile(Optional Async As Boolean = True)
Dim WavFile As String
WavFile = "tada.wav"
WavFile = "C:\Windows\Media\" & WavFile
If Async Then
Call PlaySound(WavFile, 0&, SND_ASYNC Or SND_FILENAME)
Else
Call PlaySound(WavFile, 0&, SND_SYNC Or SND_FILENAME)
End If
End Sub


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"JLGWhiz" wrote in message
...
Based on what I can glean from other threads, it seems that I could not

call
the tada.wav using VBA code in Excel 2003. If this is not true, what is

the
code. I have tried the XL2000 code and it did not work. Thanks.




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
Sounds paulport Excel Discussion (Misc queries) 2 March 28th 07 01:02 AM
Excel Sounds donpauleon Excel Discussion (Misc queries) 2 July 25th 06 07:49 AM
Excel Sounds Trojan Excel Discussion (Misc queries) 5 November 20th 05 09:42 AM
why does it sounds every minute?-Help please J_J[_2_] Excel Programming 10 February 23rd 05 07:33 PM
How disabling sounds when calling a shell program? Michel[_3_] Excel Programming 4 October 22nd 03 09:38 AM


All times are GMT +1. The time now is 02:43 AM.

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

About Us

"It's about Microsoft Excel"