- 帖子
- 4901
- 主題
- 44
- 精華
- 24
- 積分
- 4916
- 點名
- 142
- 作業系統
- Windows 7
- 軟體版本
- Office 20xx
- 閱讀權限
- 150
- 性別
- 男
- 來自
- 台北
- 註冊時間
- 2010-4-30
- 最後登錄
- 2026-7-16
                
|
本帖最後由 Hsieh 於 2011-5-3 22:32 編輯
另一個API函數用法sndPlaySound
一般模組- Private Declare Function sndPlaySound Lib "winmm.dll" Alias _
- "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
- Function SndPlay(Pathname As String) As Long
- SndPlay = sndPlaySound(Pathname, SND_ASYNC)
- End Function
複製代碼 工作表模組- Private Sub Worksheet_Calculate()
- For Each a In [B1:D1]
- If a > a.Offset(1, 0) Then
- mypath = ThisWorkbook.Path & "\" & a.Offset(2, 0)
- Application.OnTime Now + TimeValue("00:00:03") * i, "'SndPlay " & Chr(34) & mypath & Chr(34) & "'"
- i = i + 1
- Application.OnTime Now + TimeValue("00:00:03") * i, "'SndPlay " & Chr(34) & mypath & Chr(34) & "'"
- i = i + 1
- End If
- Next
- End Sub
複製代碼 B1:D2輸入公式
=RAND()
B3:D3輸入音效檔名(含副檔名)
按F9重算
WIN XP+2003版
WIN 7+2010版
測試通過
PlaySound.zip (85.04 KB)
|
|