#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default WAV files

Is it possible to call up WAV files in Excel XP? I seem to recall this was
easy in earlier versions but I can't find anything in VB help files.
Thanks.
David


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 128
Default WAV files

On Feb 3, 9:15 pm, "David Overington" wrote:
Is it possible to call up WAV files in Excel XP? I seem to recall this was
easy in earlier versions but I can't find anything in VB help files.
Thanks.
David


Hello David,

You need to call an API to play a sound file. Here is the code. Change
the file path to the sound file you want to play in the macro
"PlaySoundFile". Load this into a Standard VBA module.

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

Sub PlaySoundFile()

Dim Ret As Long
Const SND_SYNC As Long = &H0 'play synchronously (default)

Ret = PlaySound("C:\MyWavFile.wav", 0&, SND_SYNC)

End Sub

================================================== ====================================
End Macro

Sincerely,
Leith Ross
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default WAV files

Perfect!
Many thanks, Leith, for the code and the clear layout.
Regards,
David

"Leith Ross" wrote in message
...
On Feb 3, 9:15 pm, "David Overington" wrote:
Is it possible to call up WAV files in Excel XP? I seem to recall this
was
easy in earlier versions but I can't find anything in VB help files.
Thanks.
David


Hello David,

You need to call an API to play a sound file. Here is the code. Change
the file path to the sound file you want to play in the macro
"PlaySoundFile". Load this into a Standard VBA module.

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

Sub PlaySoundFile()

Dim Ret As Long
Const SND_SYNC As Long = &H0 'play synchronously (default)

Ret = PlaySound("C:\MyWavFile.wav", 0&, SND_SYNC)

End Sub

================================================== ====================================
End Macro

Sincerely,
Leith Ross



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
Excel 2007 tmp files filling up drive with XLSM files Jim Excel Worksheet Functions 0 September 12th 08 03:31 PM
How to change default Open/Files of Type to "Microsoft Excel Files Tammy Excel Discussion (Misc queries) 2 January 14th 08 11:06 PM
how to default WritePassword under excel workbook property for any files as long as those files are the offsprings of the parent file George Excel Programming 0 October 5th 06 04:14 PM
Drive Erased, got Files back but only excel files scrambled, help. Shawnky Excel Discussion (Misc queries) 0 May 8th 06 07:26 PM
Macro to open *.dat files and save as .txt (comma delimited text files) [email protected] Excel Programming 2 November 30th 05 05:50 AM


All times are GMT +1. The time now is 08:57 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"