2012-02-25 43 views

cevap

11

İşte WAV dosyaları için bir yol. Düzenli kod modülünde ** this code ** koyun: Şimdi

Option Explicit 
Public Declare Function sndPlaySound32 _ 
    Lib "winmm.dll" _ 
    Alias "sndPlaySoundA" (_ 
     ByVal lpszSoundName As String, _ 
     ByVal uFlags As Long) As Long 

Sub PlayTheSound(ByVal WhatSound As String) 
    If Dir(WhatSound, vbNormal) = "" Then 
     ' WhatSound is not a file. Get the file named by 
     ' WhatSound from the Windows\Media directory. 
     WhatSound = Environ("SystemRoot") & "\Media\" & WhatSound 
     If InStr(1, WhatSound, ".") = 0 Then 
      ' if WhatSound does not have a .wav extension, 
      ' add one. 
      WhatSound = WhatSound & ".wav" 
     End If 
     If Dir(WhatSound, vbNormal) = vbNullString Then 
      Beep   ' Can't find the file. Do a simple Beep. 
      Exit Sub 
     End If 
    Else 
     ' WhatSound is a file. Use it. 
    End If 

    sndPlaySound32 WhatSound, 0& ' Finally, play the sound. 
End Sub 

, başka makro yoluyla herhangi bir wav dosyası çalabilir Yukarıdaki rutin arama ve/Medya klasöründe bulunan herhangi dosya içinde besleyerek:

Sub PlayIt() 
    Select Case Range("A1").Value 
     Case "good" 
      PlayTheSound "chimes.wav" 
     Case "bad" 
      PlayTheSound "chord.wav" 
     Case "great" 
      PlayTheSound "tada.wav" 
    End Select 
End Sub 

Bununla oynayın.

Random Task List with AUDIO Reveal

+0

Teşekkür bağlantıyı eklemek için: yapmayı planlıyorsunuz gibi dramatik günü için rastgele isim ve görevleri ortaya çıkarmak için bu, bir düğme takılır kullanmak İşte burada

örnek bir dosya var Brett! Benim kötü ... –

+0

Sorun değil, daha çok kozmetik bir güncellemeydi. +1 btw – brettdj

İlgili konular