+ Reply to Thread
Results 1 to 5 of 5

Adding sound when workbook is opened

  1. #1
    Registered User
    Join Date
    12-19-2014
    Location
    US
    MS-Off Ver
    2010 Suite
    Posts
    28

    Adding sound when workbook is opened

    Hello,

    I am wondering if I can get a code to a wav file that I have. Then used this wav file to sound each time I open this file. Can you signify, highlight, or make an example the areas I need to change the code. This will help significantly. Thanks

  2. #2
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Adding sound when workbook is opened

    Hi gdclyde and welcome to ExcelForum,

    See post #4 in the following thread, which details how to add .wav file sound. The code requires your .wav file to be in the same file as your Excel folder. http://www.excelforum.com/excel-prog...ml#post3896943

    If you need additional help, please upload a sample workbook.

    Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic

    Lewis
    Last edited by LJMetzger; 12-23-2014 at 10:57 AM.

  3. #3
    Registered User
    Join Date
    12-19-2014
    Location
    US
    MS-Off Ver
    2010 Suite
    Posts
    28

    Re: Adding sound when workbook is opened

    Thank you very much. Let me know what else I need to do.
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Adding sound when workbook is opened

    Hi,

    See the attached file which should play your .wav file when the Workbook opens. You can also play the .wav file by 'Left Clicking' the yellow shape on Sheet1. I am only able to play .wav files that are in files. Embedded .wav files automatically open the default program that plays .wav files (Windows Media Player on my Windows Vista computer). Nothing bad will happen if the .wav file can not be found.

    In order to play the .wav files, you need to have a Macro Enabled Workbook (type .xlsm or .xlsb). You also need to have Macros enabled.

    To enable Macros and to Run Macros see the following:
    http://office.microsoft.com/en-us/ex...010031071.aspx
    http://office.microsoft.com/en-us/ex...010014113.aspx
    http://office.microsoft.com/en-us/tr...001150634.aspx
    If help is still needed do a google search for 'youtube excel enable macro' and/or 'youtube excel run macro'.

    ---------------------------

    The following is for future reference:

    When you open a workbook, Excel looks for a routine called Workbook_Open() in a special module called ThisWorkbook. If Excel finds this routine, then it executes the code in it. Most code that we write goes in Ordinary Code modules that we can name. In Workbook_Open(), I placed a call to code that I wrote to PlaySoundFile(). PlaySoundFile() executes code that verifies that your file exists, and then plays the .wav file.


    To access Visual Basic (VBA) see:
    http://www.ablebits.com/office-addin...a-macro-excel/
    a. Click on any cell in the Excel Spreadsheet (may not be needed).
    b. ALT-F11 to get to VBA.
    c. CTRL-R to get project explorer (if it isn't already showing).
    d. Double Click on a 'Module Name' in 'Project Explorer' to see code for that module.

    Debugger Secrets:
    a. Press 'F8' to single step (goes into subroutines and functions).
    b. Press SHIFT 'F8' to single step OVER subroutines and functions.
    c. Press CTRL 'F8' to stop at the line where the cursor is.
    d. 'Left Click' the margin to the left of a line to set (or clear) a BREAKPOINT.
    e. Press CTRL 'G' to open the IMMEDIATE WINDOW. 'debug.print' statements send their
    output to the IMMEDIATE WINDOW.
    f. Select View > Locals to see all variables while debugging.
    g. To automatically set a BREAKPOINT at a certain location put in the line:
    'Debug.Assert False'
    h. To conditionally set a BREAKPOINT at a certain location put in lines similar to:
    if i >= 20 and xTV20 > 99.56 then
    Debug.Assert False
    endif
    i. A variable value will be displayed by putting the cursor over the variable name.

    Code follows:
    ThisWorkbook module:
    Please Login or Register  to view this content.
    Ordinary Code Module 'ModPlaySound':
    Please Login or Register  to view this content.
    Please let me know how you make out, and if you need any additional assistance.

    Lewis
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    12-19-2014
    Location
    US
    MS-Off Ver
    2010 Suite
    Posts
    28

    Re: Adding sound when workbook is opened

    Thank you very much it works really well.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Use a macro to extract cell data from opened workbook to new opened workbook
    By BrianTFC in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-26-2014, 01:35 PM
  2. Replies: 3
    Last Post: 05-23-2013, 02:12 AM
  3. Adding an embedded sound?
    By Terry Pinnell in forum Excel General
    Replies: 0
    Last Post: 09-05-2005, 08:05 AM
  4. [SOLVED] Adding Sound to Program Revisited
    By Carlton Patterson in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-25-2005, 10:06 AM
  5. [SOLVED] Adding Sound to Program
    By Carlton Patterson in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 04-24-2005, 07:07 PM

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