View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Claus Busch Claus Busch is offline
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