DDE-EXCEL如何連結自設的音效檔?
各位先進們好:敝人盼能在已製作好的一份DDE的EXCEL檔(每日自08:45至13:45每隔若干秒會自動讀取一次)裏面加入音效上的功能,目標是當某一欄儲存格(例如R欄)數值超過100以上時則啟動某路徑連結到桌面上自設的某一個特定音效檔X發出警示音,路徑為C:\Users\Administrator\Desktop \X,同樣地數值小於100時則連結另一音效檔Y,路徑為C:\Users\Administrator\Desktop \Y,不知VBA中其程式碼應如何撰寫?
感謝賜教 本帖最後由 Seer_et 於 14-3-27 23:31 編輯
這是抄來的,你試試吧
Sub Alert()
Dim spath As String, cmd As String
spath = "C:\Users\Administrator\Desktop\超過100.wav"
cmd = "sndrec32 /play /close " & Chr(34) & spath & Chr(34)
Shell cmd, 6
End Sub
Sub Alert2()
Dim spath As String, cmd As String
spath = "C:\Users\Administrator\Desktop\小於100.wav"
cmd = "sndrec32 /play /close " & Chr(34) & spath & Chr(34)
Shell cmd, 6
End Sub
Sub 每隔若干秒執行()
IF Time < TimeValue("08:45:00") And Time > TimeValue("13:45:00") Then Exit Sub
With Activesheet
For Each x In .Range("R1",.Range("R1").end(xlDown))
If x > 100 Then Application.Run "Alert"
If x < 100 Then Application.Run "Alert2"
Next
End With
t = DateAdd("s",每隔若干秒,Time)
Application.OnTime t, "每隔若干秒執行"
End Sub
頁:
[1]