How run mp3 audio files in vba

  • Thread starter Thread starter franco2808
  • Start date Start date
F

franco2808

In office, eg excel, you can write a macro to run wav audio files. Can you do
the same for mp3 files?
 
Thanks very much Don Guillett for your help, but I need more help.
I tried this macro:

Sub pippo()
Dim fileaudio As String

fileaudio = "C:/audiomumbay/prova.mp3"
ActiveWorkbook.FollowHyperlink Address:=fileaudio

End Sub

and it does not work.

If I change the type of file:

Sub pippo()
Dim fileaudio As String

fileaudio = "C:/audiomumbay/prova.wav"
ActiveWorkbook.FollowHyperlink Address:=fileaudio

End Sub

of course with a wav file, it works well.
Maybe I have problems because I have Excel 2000?
 
May I take advantage of your kindness?
I have to link more audio files and so I want they to be played one after
another.
How can I wait for the end of an audio file playing?
 
Assuming you have the FULL path and name typed into cells. Simply select the
cells desired and fire it.

Sub playselectedfiles()
For Each song In Selection
'MsgBox song
'ActiveWorkbook.FollowHyperlink Address:=FullFileName
ActiveWorkbook.FollowHyperlink Address:=song
Next song
End Sub
 
I wrote this sub:
Sub pippo()
Dim fileaudio As String

fileaudio = "C:\audiomumbay\prova1.mp3"
ActiveWorkbook.FollowHyperlink Address:=fileaudio
fileaudio = "C:\audiomumbay\prova2.mp3"
ActiveWorkbook.FollowHyperlink Address:=fileaudio

End Sub

and what I get is that just the first file is played or sometimes only the
second is played.
By the way: the Media player windows is shown and I have to close it
manually. Is it possible to avoid the visualization of that window.
 
If you don't want to use my idea then

Sub playsongsinarray()
myarray = Array("C:\A_D\Townes Van Zandt- Racing In The Street.mp3",
"C:\A_D\Townes Van Zandt - When He Offers His Hand.mp3")
For Each song In myarray
'MsgBox song
ActiveWorkbook.FollowHyperlink Address:=song
Next song
End Sub
 
Dear Don Guillet,
I have worked on your idea but I have this problem.
Windows media player is run and the sound files are not correctlely
sequenced. Sometimes only the first is run, sometimes only the second.
I tried from media player to directly run a playlist and there are strange
behaviour (e.g. a file is played twice and another is not played). So I tried
VLC instead of Media player and the playlist work well. At this point I
changed method: instead of sequencieng audio file I composed in vba a play
list and run this playlist.
But, also if I set the defaultr application for m3u is VLC, Media player is
launched and so the file are not well sequenced. Do you know a way to specify
I want to run VLC and not media player?
 
Dear Don Guillet thanks very much for your help.
You have been so kind to help me and your suggestions has been very helpfull.
Ciao
 
Back
Top