Excel VBA To Play Specified Sound Extension File Type Without Visually Showing Any Music Player Program

jaywenp

New Member
Joined
Mar 12, 2014
Messages
42
Good Day Everyone,

I am trying to understand the limitation of Excel, In The Year 2017, as it relates to playing music/audio extension files via VBA. I have seen successful ways of playing WAV sound files without visually opening an additional music player program. Can someone PLEASE tell me if Excel can handle playing any other sound extension file types, in the same way it handles/plays a WAV sound extension file. I have seen Excel VBA used to open more modern sound extension files like MP3, however, it requires taking up valuable computer screen real-estate by visually opening your computers default music program. The goal of this inquiry is to be able to successfully open as many audio sound file types, within a specified computer file location, without visually seeing any music player program being used in connection with the VBA code. I am Hoping there is a way to generate VBA code for different sound file extension types with the same success that Excel has with handling a WAV sound extension file.

I believe it is generally better to only hear the sound of requested audio files called by VBA code opposed to having the computer screen be invaded by a visually obtrusive music player program.


Some Possible Sound File Types To Consider When Answering This Inquiry:
AAC
AIFF (Advantage: High Quality Sound vs small file size)
AIFC
Apple Lossless
BWF (Broadcast Wave Format)
FLAC
MIDI
MP3 (Advantage: Small File Size vs high quality sound)
MPA (MPEG1 layer 2)
M4A (Apple iTunes AAC)
OGG (Ogg Vorbis)
PCM WAV
Single or Multitrack Quicktime Audio
Sound Designer II
WAV (Advantage: High Quality Sound vs small file size)
WMA (including WMA Pro and WMA lossless)
WMA9 with MS DRM (security level < 2000, no transcode, no burning)


*****PLEASE advise of possible solutions to achieve the goal of this post*****


Any advice or suggestions would be greatly appreciated.

Thank You.
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Code:
Option Explicit


Private Declare Function sndPlaySound32 Lib "winmm.dll" _
Alias "sndPlaySoundA" (ByVal lpszSoundName _
As String, ByVal uFlags As Long) As Long


Sub PlySnd()
    Dim PlaySound As Boolean


        Call sndPlaySound32("C:\windows\media\chord.wav", 1)


End Sub
 
Upvote 0
The code above references a WAV sound file extension. Can you show code that might possibly play a MP3 sound file extension without visually opening a music player program?

Thanks.
 
Upvote 0
I've searched for several days and cannot find anything that provides a means of playing an MP3 file without having a player visible. Perhaps someone else can assist.
 
Upvote 0
I've searched for several days and cannot find anything that provides a means of playing an MP3 file without having a player visible. Perhaps someone else can assist.


Thank you for checking. Your time is appreciated.

I hope that someone can provide an answer to this inquiry that might be useful to others as well.


Thanks again.
 
Upvote 0
Why don't you convert the Mp3 to a WAV file.
There are plenty of free converters out there.
I'm guessing file size could be an issue though.
 
Upvote 0
Yes, changing the file type through a converter program does keep the ability to play the sound file. However, as you pointed out WAV files can take up a lot of memory. Additionally, if it were possible, I believe it would be best if someone would not have to spend extra time converting each music file to meet the objective of this Excel inquiry.

I do thank you very much for your suggestion.

I hope there is still an option out there that will not require a file conversion. Any additional comments or suggestions are appreciated.
 
Upvote 0
I don't believe there is another option !!
You could clip the Mp3 file down to a suitable size....but that would depend on the requirements
 
Upvote 0
Code:
Option Explicit


Private Declare Function sndPlaySound32 Lib "winmm.dll" _
Alias "sndPlaySoundA" (ByVal lpszSoundName _
As String, ByVal uFlags As Long) As Long


Sub PlySnd()
    Dim PlaySound As Boolean


        Call sndPlaySound32("C:\windows\media\chord.wav", 1)


End Sub
Awesome. I spent HOURS trying different vba code, and this one was SPOT-ON for me. Excel 2k
 
Upvote 0
The winmm.dll library exports the mciSendString api function which can play different file sound formats w\o showing the sound player software.
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,159
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top