Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 86
Default Is BEEP all there is??

Is there any functionality in VBA to produce tones of varying pitch ,
intensity, and duration similar to the SOUND command in earlier versions of
BASIC?
--
Gary's Student
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 983
Default Is BEEP all there is??

Here is an API to play whatever wav file makes you happy.

Option Explicit

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


Private Sub Test()
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

"Gary's Student" wrote:

Is there any functionality in VBA to produce tones of varying pitch ,
intensity, and duration similar to the SOUND command in earlier versions of
BASIC?
--
Gary's Student

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 86
Default Is BEEP all there is??

Thanks, I guess the burden has shifted from programming Basic to make sounds
to programming some other software to make .wav files?
--
Gary's Student


"Jim Thomlinson" wrote:

Here is an API to play whatever wav file makes you happy.

Option Explicit

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


Private Sub Test()
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

"Gary's Student" wrote:

Is there any functionality in VBA to produce tones of varying pitch ,
intensity, and duration similar to the SOUND command in earlier versions of
BASIC?
--
Gary's Student

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Is BEEP all there is??

In xl9x I believe Beep is all there is. In NT/XP/2003, you can control the
internal speaker (which makes the beep)

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

Sub Beep1()
Dim num As Single
Dim num1 As Long
Dim numLoops As Single
num = 10
NumSeconds = 4 '<== duration
numLoops = (NumSeconds * num * 2) / 2
If numLoops < 1 Then
numLoops = 1
End If
num1 = 1000 / (num * 2)

For i = 1 To numLoops
'DoEvents
Beep 500, num1
'DoEvents
Beep 10000, num1
'DoEvents
Next
End Sub


The first argument is the frequency. You can change the 10000 (you can't
hear that) to 1000 to get a different affect for example.

--
Regards,
Tom Ogilvy

"Gary's Student" wrote in message
...
Thanks, I guess the burden has shifted from programming Basic to make

sounds
to programming some other software to make .wav files?
--
Gary's Student


"Jim Thomlinson" wrote:

Here is an API to play whatever wav file makes you happy.

Option Explicit

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

Long


Private Sub Test()
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

"Gary's Student" wrote:

Is there any functionality in VBA to produce tones of varying pitch ,
intensity, and duration similar to the SOUND command in earlier

versions of
BASIC?
--
Gary's Student



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 86
Default Is BEEP all there is??

Thank you both very much.
--
Gary's Student


"Tom Ogilvy" wrote:

In xl9x I believe Beep is all there is. In NT/XP/2003, you can control the
internal speaker (which makes the beep)

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

Sub Beep1()
Dim num As Single
Dim num1 As Long
Dim numLoops As Single
num = 10
NumSeconds = 4 '<== duration
numLoops = (NumSeconds * num * 2) / 2
If numLoops < 1 Then
numLoops = 1
End If
num1 = 1000 / (num * 2)

For i = 1 To numLoops
'DoEvents
Beep 500, num1
'DoEvents
Beep 10000, num1
'DoEvents
Next
End Sub


The first argument is the frequency. You can change the 10000 (you can't
hear that) to 1000 to get a different affect for example.

--
Regards,
Tom Ogilvy

"Gary's Student" wrote in message
...
Thanks, I guess the burden has shifted from programming Basic to make

sounds
to programming some other software to make .wav files?
--
Gary's Student


"Jim Thomlinson" wrote:

Here is an API to play whatever wav file makes you happy.

Option Explicit

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

Long


Private Sub Test()
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

"Gary's Student" wrote:

Is there any functionality in VBA to produce tones of varying pitch ,
intensity, and duration similar to the SOUND command in earlier

versions of
BASIC?
--
Gary's Student






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 983
Default Is BEEP all there is??

Thanks Tom... One more API for me ply with...

"Tom Ogilvy" wrote:

In xl9x I believe Beep is all there is. In NT/XP/2003, you can control the
internal speaker (which makes the beep)

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

Sub Beep1()
Dim num As Single
Dim num1 As Long
Dim numLoops As Single
num = 10
NumSeconds = 4 '<== duration
numLoops = (NumSeconds * num * 2) / 2
If numLoops < 1 Then
numLoops = 1
End If
num1 = 1000 / (num * 2)

For i = 1 To numLoops
'DoEvents
Beep 500, num1
'DoEvents
Beep 10000, num1
'DoEvents
Next
End Sub


The first argument is the frequency. You can change the 10000 (you can't
hear that) to 1000 to get a different affect for example.

--
Regards,
Tom Ogilvy

"Gary's Student" wrote in message
...
Thanks, I guess the burden has shifted from programming Basic to make

sounds
to programming some other software to make .wav files?
--
Gary's Student


"Jim Thomlinson" wrote:

Here is an API to play whatever wav file makes you happy.

Option Explicit

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

Long


Private Sub Test()
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

"Gary's Student" wrote:

Is there any functionality in VBA to produce tones of varying pitch ,
intensity, and duration similar to the SOUND command in earlier

versions of
BASIC?
--
Gary's Student




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
Beep on greater than zero TaylorLeigh New Users to Excel 1 September 29th 08 11:14 PM
BEEP ziad Excel Discussion (Misc queries) 5 December 28th 07 03:56 PM
turn off beep jocke Excel Discussion (Misc queries) 0 May 31st 06 07:54 AM
I want to *beep* *beep*!!!! Jake Marx[_3_] Excel Programming 1 February 22nd 04 01:00 PM
I want to *beep* *beep*!!!! KJTFS[_105_] Excel Programming 0 February 20th 04 02:59 PM


All times are GMT +1. The time now is 10:37 PM.

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"