Det er en Wav fil. Jeg har Win XP. Jeg har prøvet nedenstående kode, men jeg vil gerne have at filen starter, når regnearket starter, eller hvis jeg trykker på en knap :-)
Public Function PlaySoundFileB(ByVal sndFileName As String) As Boolean
Dim iSuccess As Integer iSuccess = PlaySound(sndFileName, 0&, SOUND_FILENAME) If iSuccess = 0 Then PlaySoundFileB = False Else PlaySoundFileB = True End If
End Function
'===== Test the functions ====== Sub TestSounds()
Debug.Print PlaySoundFileB("C:\Documents and Settings\bejstrup\Skrivebord\Test.wav") Debug.Print PlaySoundFileA("C:\Documents and Settings\bejstrup\Skrivebord\Test.wav")
Private Declare Function sndPlaySound Lib "winmm.dll" _ Alias "sndPlaySoundA" _ (ByVal lpszSoundName As String, _ ByVal uFlags As Long) As Long
Private Declare Function PlaySound Lib "winmm.dll" _ Alias "PlaySoundA" _ (ByVal lpszName As String, _ ByVal hModule As Long, _ ByVal dwFlags As Long) As Long
Private Const SOUND_FILENAME = &H20000
Public Function PlaySoundFileA(sndFileName As String) As Boolean
Dim iSuccess As Integer iSuccess = sndPlaySound(sndFileName, SOUND_FILENAME) If iSuccess = 0 Then PlaySoundFileA = False Else PlaySoundFileA = True End If
End Function
Private Sub Workbook_Open()
Debug.Print PlaySoundFileA("C:\Documents and Settings\bejstrup\Skrivebord\Test.wav")
Jeg får en compile error med: Only commente may appear after end Sub end Function or end property. Den stopper ved: Private Declare Function sndPlaySound Lib "winmm.dll" _ Alias "sndPlaySoundA" _ (ByVal lpszSoundName As String, _ ByVal uFlags As Long) As Long
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.