Generating a sound

iibobii

New Member
Joined
Feb 26, 2002
Messages
40
I know, I know, this is a stupid question, and you're wondering why would I ever want to do this, but is there any way to generate a sound (say a wav file) when you initially open an Excel document?

Thanks.
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Thanks a ton. Didn't really think it was possible. I'll give it a try. Glad to see that there are other wacked people out there. :)
 
Upvote 0
Sorry, but not being anywhere NEAR an Excel expert, I'm struggling on this one. I'm not sure what a Module is. Also, in your example, the name of the file was MyWavFile. Does that name go anywhere else or just on the Call line? Can you help me out a bit more...guess I need some hand holding on this one...

THANKS!
 
Upvote 0
Hey Joe...if you have a second, can you check your private messages...had one more question.

Thanks!
 
Upvote 0
On 2002-03-08 06:22, iibobii wrote:
Sorry, but not being anywhere NEAR an Excel expert, I'm struggling on this one. I'm not sure what a Module is. Also, in your example, the name of the file was MyWavFile. Does that name go anywhere else or just on the Call line? Can you help me out a bit more...guess I need some hand holding on this one...

THANKS!

If all you're wanting is to play this wav file when you open Excel, I can talk you through it. This example is if you want this to play every time your Excel opens.

1. Open a new Excel workboox.
2. Right Click on the Icon to the left of "File" on the main menu.
3. Choose "View Code"
4. Copy and Paste this code into the window that opens up:

<pre>

' ***************************************************************************
' * Instructions: Paste the lines below into a module, or into your form, and
' * call using the example below.
' * Example:
' * CALL PlayWavFile ("C:MyWavFile.wav")
' ***************************************************************************

Const SND_SYNC = &H0
Const SND_ASYNC = &H1
Const SND_NODEFAULT = &H2
Const SND_LOOP = &H8
Const SND_NOSTOP = &H10

Private Declare Function sndPlaySoundA Lib "WINMM.DLL" (ByVal lpszSoundName As String, ByVal ValueFlags As Long) As Long

Private Sub PlayWavFile(ByVal pFilename As String)
Dim Ret As Long

Ret = sndPlaySoundA(pFilename, SND_ASYNC Or SND_NODEFAULT)
End Sub
Private Sub Workbook_Open()

'This line of code is all you need to change
PlayWavFile "C:TempGoBlue.wav"

End Sub
</pre>

5. Change the part of the code that says "C:TempGoBlue.wav" to the fulle path of your wav file.
6. Now got to "File|Save Book1"
7. Rename the file to whatever you want e.g. "PlaySound" and change the "Save As Type" combobox to be "Excel Add In *.xla" (this is the last option in the combobox.)

Now for the interesting part

8. Go back to your Excel spreadsheet and choose "Tools|Add Ins".
9. In the list you will hopefully find "PlaySound" or whatever you've named your *.xla.
10. Check the box beside this.
11. When you next open Excel this should play the file for you.

Hope this works for you.
 
Upvote 0
****, I got timed out, that anonymous post was from me.

I put that whole message there because there's no point in solving people's problems by private message. Private messages defeat the purpose of the message board.

Cheers
 
Upvote 0
The reason I sent a private message with some pointers was as a backup if you didnt send an answer, hence the words "if you need it". I didn't want to tread on yout toes or appear to be cutting in. Besides which, all I did was give some pointers on how to set a module up, not exactly rocket science.

I do apologise though, next time I'll check my book, "How To Use A Message Board"
This message was edited by Audiojoe on 2002-03-08 07:04
 
Upvote 0
Hi Mark. Thanks a ton. I think I'm close, but it won't work yet. When I right mouse click and choose View Code, it opens up to an "Open" book. Do I add it after what's typed there or somewhere else?

...I'll eventually get this... I hope... Thanks for your patience.
 
Upvote 0

Forum statistics

Threads
1,213,496
Messages
6,113,993
Members
448,539
Latest member
alex78

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top