Making a "ding" sound in the macro process

I

iashorty

Here is a macro written by someone before me:
Sub ding1()
'
' Ding Macro
MultiBeep 5
Message
End Sub

Sub MultiBeep(numbeeps)
For counter = 1 To numbeeps
Beep
Next counter
End Sub

Sub Message()
MsgBox "Sorry, I have not been assigned yet!"
End Sub

The macro goes through the process but the dings are not audible. I was
instructed to make this work, but I can't find any information on Beeps or
Dings.
 
C

Chip Pearson

Try some code like the following:

Declare Function sndPlaySound32 Lib "winmm.dll" Alias _
"sndPlaySoundA" (ByVal lpszSoundName As String, _
ByVal uFlags As Long) As Long

Sub PlayChimes()
Dim N As Long
For N = 1 To 5
sndPlaySound32 "chimes", 0
Next N
End Sub


Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)
 
M

Mike H

Hi,

On the assumption you have speakers and they are switched on your code will
produce 5 beeps. However they will be so quick you will only hear one of
them. Introduce a pause with this line


Sub MultiBeep(numbeeps)
For counter = 1 To numbeeps
Beep
Application.Wait (Now + TimeValue("0:00:01"))
Next counter
End Sub

Mike
 
I

iashorty

I don't understand your declaration Function paragraph. Is this exactly what
I should type?
 
I

iashorty

I don't even hear one beep. Putting a hesitation in the macro didn't help. I
hear the beeping of a new Lotus Sametime coming in so I know the speakers are
on.
 
I

iashorty

i need to explain that I am an accountant not a programmer. I have not had
any Visual Basic, just a logic and some experience in Excel and writing
macros. What I don't know, I've had to ask for help. Assume I know nothing
and maybe this will make sense to me.
 
C

Chip Pearson

The "Declare" statement is used to specify a function that resides in
a Windows DLL file, which is completely and fully disconnected in
every way from VBA and Excel. Windows is a collections of hundreds (?)
of individual DLL files (DLL = Dynamic Link Library), organized by
functionality. When you "Declare" a function, you instruct VBA to go
to that DLL file and execute the named function in that DLL. The
"Declare" statement must reside before and outside of any VBA
procedure (e.g., a Sub or Function procedure). It is worth noting
that when you use a DLL function with a Declare statement, you are
bypassing all of VBA's safety and error mechanisms. Any error in the
declaration of the DLL function or in the parameters passed to that
functions will likely cause Excel to crash. DLL functions can allow
you to do things not supported by Excel/VBA and they are very fast,
but they can be dangerous because VBA isn't involved to handle errors.

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top