View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Howard Howard is offline
external usenet poster
 
Posts: 536
Default PlaySound error (Chip Pearson site)

At Chip's site the directions say to run this ListWavFiles code, which I did and it did list the sounds as per per instructions.

Then per instructions (see below) run the PlayActiveCellSound code with a sound selected on the worksheet. This errors out on the single line of code with <PlayTheSound highlighted. Wants a "sub or method defined..."

Have tried it in the sheet and an insert module.

http://www.cpearson.com/excel/PlaySound.aspx
Option Explicit
Sub ListWavFiles()
Dim N As Long
Dim FSO As Object
Dim FF As Object
Dim F As Object
Set FSO = CreateObject("Scripting.FileSystemObject")
Set FF = FSO.GetFolder(Environ("SystemRoot") & "\Media")
For Each F In FF.Files
N = N + 1
Cells(N, 1) = F.Name
Cells(N, 2) = F.Path
Next F
ActiveSheet.Columns(1).AutoFit
End Sub

'This code will list in column A all the wav files in _
'C:\Windows\Media and put the fully qualified file name in column B. _
'To play one of these sounds, select the cell in either column A or B and execute the following code:

Sub PlayActiveCellSound()
PlayTheSound ActiveCell.Text
End Sub

Thanks,
Howard