ich würde gerne in einer Datei ab F6 untereinander Hyperlinks zu MP3-Dateien einfügen und mittels Autofilter sortieren. Alles kein Problem.
Das Problem: Ich möchte per Doppellklick oder per Command-Button die Datei abspielen.
Meine Recherche in dieser Richtung war von Josef Ehernsberger
https://www.herber.de/bbs/user/29543.xls
aber die Datei muss abc.mp3 heißen.
In dieser Arbeitmappe:
Option Explicit
Private Sub Workbook_Deactivate()
' MP3-Wiedergabe stoppen
MP3_Stop "MyAlias"
End Sub
'+++++++++
In der Tabelle
Option Explicit
Const myMP3 As String = "C:\abc.mp3"
Dim blnDontPlayAgain As Boolean
Private Sub Worksheet_Calculate()
If [A1] > 20 Then
If Not blnDontPlayAgain Then
' MP3 abspielen
MP3_Play myMP3, "MyAlias"
blnDontPlayAgain = True
End If
Else
' MP3-Wiedergabe stoppen
MP3_Stop "MyAlias"
blnDontPlayAgain = False
End If
End Sub
'+++++++
Im Modul mdPlayMP3
' Modul MP3-Play and Stop via API
'Quelle: http://www.vbarchiv.net/archiv/tipp_499.html
Option Explicit
' zunächst die benötigte API-Deklaration
Private Declare Function mciSendString Lib "winmm.dll" _
Alias "mciSendStringA" (ByVal lpszCommand As String, _
ByVal lpszReturnString As String, _
ByVal cchReturnLength As Long, _
ByVal hwndCallback As Long) As Long
Private Declare Function GetShortPathName Lib "kernel32" _
Alias "GetShortPathNameA" (ByVal lpszLongPath As String, _
ByVal lpszShortPath As String, _
ByVal cchBuffer As Long) As Long
' MP3-Datei abspielen
Public Function MP3_Play(ByVal sFile As String, _
ByVal sAlias As String) As Boolean
Dim bResult As Boolean
' Dateinamen in DOS 8.3 Format, da z.B. Sonderzeichen
' wie Leerzeichen Probleme machen
Dim sBuffer As String
Dim lResult As Long
sBuffer = Space$(255)
lResult = GetShortPathName(sFile, sBuffer, Len(sBuffer))
If lResult 0 Then
sFile = Left$(sBuffer, InStr(sBuffer, vbNullChar) - 1)
' MCI öffnen
lResult = mciSendString("open " & sFile & _
" type MPEGVideo alias " & sAlias, 0, 0, 0)
If lResult = 0 Then
' MP3 abspielen
If mciSendString("play " & sAlias & _
" from 0", 0, 0, 0) = 0 Then
bResult = True
End If
End If
End If
MP3_Play = bResult
End Function
' Wiedergabe stoppen und MCI schließen
Public Sub MP3_Stop(ByVal sAlias As String)
mciSendString "stop " & sAlias, 0, 0, 0
mciSendString "close " & sAlias, 0, 0, 0
End Sub
Meine Frage: wie bekomme ich den ode auf meine Anwendung?
Vielen Dank im voraus
Werner