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:
Ordinary Code Module 'ModPlaySound':
Please let me know how you make out, and if you need any additional assistance.
Lewis
Bookmarks