Error Checking in Excel
Thanks Thanks:  0
Likes Likes:  0
Page 1 of 3 123 LastLast
Results 1 to 10 of 25

Thread: Generating a sound

  1. #1
    New Member
    Join Date
    Feb 2002
    Posts
    40
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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.

  2. #2
    MrExcel MVP Mark O'Brien's Avatar
    Join Date
    Feb 2002
    Location
    Columbus, OH, USA
    Posts
    3,530
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    I have done this and I did it as a joke on some people's machines, so I'm not wondering why you're wanting this at all.

    Here's a link to a for an example:

    http://www.zarr.net/vb/download/codedetail.asp?code=217



    HTH

  3. #3
    New Member
    Join Date
    Feb 2002
    Posts
    40
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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.

  4. #4
    New Member
    Join Date
    Feb 2002
    Posts
    40
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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!

  5. #5
    Board Regular
    Join Date
    Feb 2002
    Location
    Where the wild roses grow
    Posts
    285
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Hiya, I've sent you some help via your private messages if you need it

    Good luck


  6. #6
    New Member
    Join Date
    Feb 2002
    Posts
    40
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

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

    Thanks!

  7. #7
    Guest

    Default

    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:



    ' ***************************************************************************
    ' * 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


    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.

  8. #8
    MrExcel MVP Mark O'Brien's Avatar
    Join Date
    Feb 2002
    Location
    Columbus, OH, USA
    Posts
    3,530
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    ****, 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


  9. #9
    Board Regular
    Join Date
    Feb 2002
    Location
    Where the wild roses grow
    Posts
    285
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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 ]

  10. #10
    New Member
    Join Date
    Feb 2002
    Posts
    40
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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.

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •