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.