Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,872
Default PlaySound error (Chip Pearson site)

Hi Howard,

Am Mon, 11 Mar 2013 11:30:55 -0700 (PDT) schrieb Howard:

Sub PlayActiveCellSound()
PlayTheSound ActiveCell.Text
End Sub


in a standard module:
Private Declare Function sndPlaySound Lib "winmm.dll" _
Alias "sndPlaySoundA" (ByVal lpszSoundName As String, _
ByVal uFlags As Long) As Long

Const SND_SYNC = &H0
Const SND_ASYNC = &H1
Const SND_LOOP = &H8
Const SND_PURGE = &H40

Public Sub SoundPlayAsyncOnce(Sound As String)
'SND_SYNC to play assynchron
sndPlaySound Sound, SND_ASYNC
End Sub

Then put a activeX-CommandButton on the sheet and copy this code to the
button:
Private Sub CommandButton1_Click()
SoundPlayAsyncOnce ActiveCell.Value
End Sub


Regards
Claus Busch
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 536
Default PlaySound error (Chip Pearson site)

On Monday, March 11, 2013 12:07:42 PM UTC-7, Claus Busch wrote:
Hi Howard,



Am Mon, 11 Mar 2013 11:30:55 -0700 (PDT) schrieb Howard:



Sub PlayActiveCellSound()


PlayTheSound ActiveCell.Text


End Sub




in a standard module:

Private Declare Function sndPlaySound Lib "winmm.dll" _

Alias "sndPlaySoundA" (ByVal lpszSoundName As String, _

ByVal uFlags As Long) As Long



Const SND_SYNC = &H0

Const SND_ASYNC = &H1

Const SND_LOOP = &H8

Const SND_PURGE = &H40



Public Sub SoundPlayAsyncOnce(Sound As String)

'SND_SYNC to play assynchron

sndPlaySound Sound, SND_ASYNC

End Sub



Then put a activeX-CommandButton on the sheet and copy this code to the

button:

Private Sub CommandButton1_Click()

SoundPlayAsyncOnce ActiveCell.Value

End Sub





Regards

Claus Busch

--

Win XP PRof SP2 / Vista Ultimate SP2

Office 2003 SP2 /2007 Ultimate SP2



Claus,

Bells & whistles & Hi-Ho's galore!

That does it and I thank you.

Regards,
Howard
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Chip Pearson UDF returns #VALUE! error please help, just cannotfigure out why? Mark Stephens Excel Programming 4 December 24th 12 08:16 AM
Thank you Chip Pearson Michael Excel Discussion (Misc queries) 3 February 5th 05 08:35 PM
Chip Pearson Ricardo[_2_] Excel Programming 0 November 10th 03 07:51 PM
CHIP PEARSON - THANX bertieBassett Excel Programming 0 November 3rd 03 02:01 PM
Chip Pearson or someone Chip Pearson Excel Programming 3 September 18th 03 05:22 AM


All times are GMT +1. The time now is 11:46 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"