+ Reply to Thread
Results 1 to 10 of 10

Play Wav File and do other stuff while playing

  1. #1
    Valued Forum Contributor realniceguy5000's Avatar
    Join Date
    03-20-2008
    Location
    Fl
    MS-Off Ver
    Excel 2003 & 2010
    Posts
    951

    Play Wav File and do other stuff while playing

    Hi,

    I have this small script below which plays a wav file which works fine. However the script stops until the wav file is completed.

    How can I make the Script continue on instead of waiting?

    Also:
    Is it possible for the wav file to keep playing over and over again till the user clicks the commandbutton1 or the commandbutton1 is not visible?

    Thank You for the help, Mike

    Please Login or Register  to view this content.
    Last edited by realniceguy5000; 10-27-2011 at 12:59 PM.

  2. #2
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: Play Wav File and do other stuff while playing

    Post the PlayWav3 routine.

    For an embedded file playing from a userform:
    Please Login or Register  to view this content.
    An API method: http://www.vbaexpress.com/forum/showthread.php?t=37056
    Last edited by Kenneth Hobson; 10-26-2011 at 12:11 PM.

  3. #3
    Valued Forum Contributor realniceguy5000's Avatar
    Join Date
    03-20-2008
    Location
    Fl
    MS-Off Ver
    Excel 2003 & 2010
    Posts
    951

    Re: Play Wav File and do other stuff while playing

    Sorry for the delay I way in a meeting. Here is the routine you requested,

    Thanks for looking...

    Please Login or Register  to view this content.

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Play Wav File and do other stuff while playing

    Hello realniceguy2000,

    You need to add in the SND_LOOP constant.
    Please Login or Register  to view this content.

    To stop the sound use this macro.
    Please Login or Register  to view this content.
    Last edited by Leith Ross; 10-26-2011 at 01:31 PM.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  5. #5
    Valued Forum Contributor realniceguy5000's Avatar
    Join Date
    03-20-2008
    Location
    Fl
    MS-Off Ver
    Excel 2003 & 2010
    Posts
    951

    Re: Play Wav File and do other stuff while playing

    Thank You,

    But how cant I make the script keep running. When I run or step through the script the wav file starts playing and the script stops till the wav file completes then the script starts up again.

    For Example: Once the script goes to the playwav3 script it will not return tll the wav completes playing.

    What I would like is the wav to keep playing while the rest of the script runs then the wav can stop once the button is clicked.

    This code below is is all in a sheet mod that is triggered when the workbook is opened. In a reg mod 1 is where I have the Declare Function part of the script.

    Any other idea's

    Thanks Mike

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Play Wav File and do other stuff while playing

    Hello Mike,

    I will have to play with this. The SND_ASYNC should return back to the calling macro after the sound file has been started. The file should continue to play until you run the macro to stop it.

  7. #7
    Valued Forum Contributor realniceguy5000's Avatar
    Join Date
    03-20-2008
    Location
    Fl
    MS-Off Ver
    Excel 2003 & 2010
    Posts
    951

    Re: Play Wav File and do other stuff while playing

    Here is a mini test file I put together it has the same problem.

    Thanks for looking, Mike
    Attached Files Attached Files

  8. #8
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Play Wav File and do other stuff while playing

    Hello Mike,

    These two macro work fine for me.
    Please Login or Register  to view this content.

  9. #9
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: Play Wav File and do other stuff while playing

    Mike, do not use NewOpen2 in sheet code.

    Sheet1's code should be:
    Please Login or Register  to view this content.
    The Module's code should be:
    Please Login or Register  to view this content.
    Last edited by Kenneth Hobson; 10-26-2011 at 04:58 PM.

  10. #10
    Valued Forum Contributor realniceguy5000's Avatar
    Join Date
    03-20-2008
    Location
    Fl
    MS-Off Ver
    Excel 2003 & 2010
    Posts
    951

    Re: Play Wav File and do other stuff while playing

    Just wanted to let you guys know everything is working now.

    Thanks for all the help, Mike

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1