• Skip to main content
  • Skip to header right navigation
  • Skip to site footer

My Online Training Hub

Learn Dashboards, Excel, Power BI, Power Query, Power Pivot

  • Courses
  • Pricing
    • Free Courses
    • Power BI Course
    • Excel Power Query Course
    • Power Pivot and DAX Course
    • Excel Dashboard Course
    • Excel PivotTable Course – Quick Start
    • Advanced Excel Formulas Course
    • Excel Expert Advanced Excel Training
    • Excel Tables Course
    • Excel, Word, Outlook
    • Financial Modelling Course
    • Excel PivotTable Course
    • Excel for Customer Service Professionals
    • Excel for Operations Management Course
    • Excel for Decision Making Under Uncertainty Course
    • Excel for Finance Course
    • Excel Analysis ToolPak Course
    • Multi-User Pricing
  • Resources
    • Free Downloads
    • Excel Functions Explained
    • Excel Formulas
    • Excel Add-ins
    • IF Function
      • Excel IF Statement Explained
      • Excel IF AND OR Functions
      • IF Formula Builder
    • Time & Dates in Excel
      • Excel Date & Time
      • Calculating Time in Excel
      • Excel Time Calculation Tricks
      • Excel Date and Time Formatting
    • Excel Keyboard Shortcuts
    • Excel Custom Number Format Guide
    • Pivot Tables Guide
    • VLOOKUP Guide
    • ALT Codes
    • Excel VBA & Macros
    • Excel User Forms
    • VBA String Functions
  • Members
    • Login
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member

Play Audio and Video in Excel

You are here: Home / Excel VBA / Play Audio and Video in Excel
play audio and video files in excel
December 13, 2018 by Philip Treacy

We've had a few forum questions recently asking how to play audio files in Excel.

Normally I'd just use my media player for this but I can see that you might want to have an audio or video file that may explain something about your workbook. Or you could use Excel to play videos in order to do some training of staff.

The ability to do this kind of thing is there, so in this post I'm going to show you how to do it.

ActiveX Controls

You're going to need to insert some ActiveX controls so you will need to enable the Developer tab if you haven't already done this.

Required Controls

I'm going to use the Windows Media Player control, and a Command Button we can click to move to the next audio/video file.

To insert these, from the Developer tab, click on Insert, then More Controls. From the pop-up window, scroll down to Windows Media Player, select it and click OK.

You'll now see that your mouse pointer has changed to a cross. Click on the sheet and drag the box to the size you want the player to be.

insert windows media player control

Using a command button will allow us to click on it and load the next audio/video file. Click Insert, click on the ActiveX Command Button, and drag it to the size and position you want.

insert command button control

Editing Control Properties

By default the name and text on the button are CommandButton1, I want to change this. First, make sure you are in Design Mode.

On the Developer tab, Design Mode mode should be colored/highlighted to indicate that you are in Design Mode. When this is the case the controls won't carry out their usual functions.

design mode

Right click on the button and click on Properties. In the Properties window, I've changed the caption to 'Next' and changed the button's name to 'NextMediaFile'. We use the name in our VBA code so it's important to have something meaningful.

Command button properties

Loading Media Files into the Player

We'll come back to the VBA that loads the media files in a second, first I want to look at how we know what to play.

What I have done is use a specific cell, A3, to tell me the folder where the files are, and below that is a list of the files I want to play.

Please note that the filename must include the extension.

You could create a playlist in Windows Media Player and load that, and it will play everything in the playlist.

VBA

We want to click the 'Next' command button to load the next file so to do that we need a little VBA

Make sure you are in Design Mode, and right click the button. Click on 'View Code' and the VBA editor will open with an empty sub already created for you.

Note that the name of the sub is taken from the name we gave the button. Now you just need to enter the code to do the fancy stuff.

Download the VBA & Workbook

Enter your email address below to download the sample workbook.

By submitting your email address you agree that we can email you our Excel newsletter.
Please enter a valid email address.

Download the Excel Workbook. Note: This is a .xlsm file please ensure your browser doesn't change the file extension on download.

vba to load next media file

How the Code Works

Each time the button is clicked the ActiveCell is moved down one row.

The code uses the ActiveCell to load the next file. If that cell is empty it goes to the start again, cell A4.

The file listed in the ActiveCell is loaded into the media player.

The code makes the assumption that there isn't anything else on the sheet, so if you happen to have F34 selected, it won't have anything in it. That being the case, the code will go back to the start of the media files and play the first one.

play audio and video files in excel

More Excel VBA Posts

Display All Matches from Search in Userform ListBox

Display All Matches from Search in Userform ListBox

Search a range for all partial and full matches of a string, and display matching records (entire rows) in a userform listbox. Sample code and userform.
animating excel charts

Animating Excel Charts

Use animation correctly to enhance the story your data is telling. Don't animate your chart just for some eye candy. Sample code and workbook to download.
dynamic data validation lists in userforms

Dynamic Data Validation Lists in Userforms

Data validation lists using the same source that are dynamically modified to prevent the same choice being made in each list.
show report filter pages for power pivot pivottables

Show Report Filter Pages for Power Pivot PivotTables

PivotTables created from Power Pivot can't use the 'Show Report Filter Pages' option. But this piece of VBA allows you to do just that.
charting real time data in excel

Charting Real Time Data in Excel

Receive data in real time and chart the data as it arrives. Can be used to chart things like stock prices or sensor readings. Sample code and workbook
select multiple items from drop down data validation list

Select Multiple Items from Drop Down (Data Validation) List

Choose multiple items from a data validation (drop down) list and store them all in the same cell. Sample workbook with working VBA.
Excel Calendar (Date Picker) to Use in Worksheets and Userforms

Multi-Language Excel Calendar (Date Picker) for Worksheets and Userforms

Easy to use, highly customizable and multi-language. This date picker is implemented as a userform that is simple to integrate into your workbook.
automating and emailing pivot table reports

Automating and Emailing Pivot Table Reports

Automate the creation and distribution of pivot table reports with some VBA. Send reports to multiple email recipients using Outlook.
search for data with userform

Searching for Data With a User Form

Search a list of records (like a table) using a user form, and then populate the fields of the search form when the record is found.
Checking values in range objects with vba

Checking Values in Range Objects With VBA

Use built in tools or your own code to examine the values contained within Range objects in VBA. Sample code to download.


Category: Excel VBA
Previous Post:excel dynamic arraysExcel Dynamic Arrays
Next Post:Excel Sorted Dynamic Unique ListExcel Sorted Dynamic Unique List

Reader Interactions

Comments

  1. George

    February 2, 2022 at 6:31 am

    Nice but it doesn’t play youtube videos.. So if you send the excel file to another person he will never see the video because it is saved in your local hardrive… I also tried with cloud and onedrive it doesn’t work.. Any idea how to play an online video ???? Media player (even if at 2022) cannot play youtube videos

    Reply
    • Philip Treacy

      February 3, 2022 at 11:17 am

      Hi George,

      There’s an Add-In called Web Video Player that seems to be able to play YT vids. You can load if from the Ribbon -> Insert -> Get Add-Ins

      regards

      Phil

      Reply
  2. Stephen Luke

    May 3, 2021 at 1:41 am

    I want to add a wav file and include a start, pause and a stop button for the audio files. I don’t want Microsoft media player I just want the audio file on the spreadsheet with the buttons. At time I may have 3 or 4 recording (wav file) that I need to put in my report but I cant work out how to add the buttons. If I put the Microsoft media player onto the spreadsheet it takes up a lot of real estate and I only need the audio. Can you help

    Reply
    • Philip Treacy

      May 4, 2021 at 8:58 am

      Hi Stephen,

      You need something to play the audio and that’s the Windows Media Player. You can reduce the size of the WMP control by shrinking it using the control’s pull handles so that only the buttons/play bar are visible.

      If you want further assistance please open a topic in our forum and attach your file.

      Regards

      Phil

      Reply
  3. Simon Jacobs

    December 12, 2020 at 8:14 am

    Thanks for helping me add audio to a spreadsheet, but could you describe how to start an audio track when the spreadsheet opens? And also not display the media player. (Does it matter what the default player is or if the user has an audio player at all?)

    It would only be one mp3 file that would be looped unless the user chooses to pause the audio from a supplied button.

    Reply
    • Catalin Bombea

      December 17, 2020 at 7:01 pm

      Hi Simon,
      To play the file in loop, you have to add this code:
      WindowsMediaPlayer1.URL = “c:\test.mp3”
      WindowsMediaPlayer1.Controls.play
      WindowsMediaPlayer1.settings.setMode “loop”, True
      To play when the file is open, you have to use the Workbook_Open event that should call your procedure.
      Workbook & Worksheet Events in Excel VBA

      Reply
  4. Sandeep Kothari

    December 23, 2018 at 12:57 pm

    Great stuff. Are ActiveX controls safe to use? Is there a similar feature under forms control?

    Reply
    • Philip Treacy

      December 23, 2018 at 1:37 pm

      Thanks Sandeep.

      ActiveX controls are as safe as macros. If you trust who wrote it, or you know what the control does then it shouldn’t pose a problem for you.

      There is no multimedia player controls in the Forms Controls.

      Regards

      Phil

      Reply
  5. Sunny Kow

    December 22, 2018 at 1:42 am

    Hi Philip

    Is the ActiveX Windows Media Player you embedded same as the version that comes together with Windows?

    The WMP that comes with Windows 10 can show subtitles/captions if the associated SRT files are present. Just exploring to see if the captions can be shown as well in Excel.

    This question was asked before about 2 years ago at the forum.
    https://www.myonlinetraininghub.com/excel-forum/vba-macros/playing-a-window-media-players-playlist-in-excel#p2031

    Reply
    • Philip Treacy

      December 23, 2018 at 1:29 pm

      Hi Sunny,

      Yes, I just selected the control from the list in Excel. I didn’t install anything different before that.

      If I watch a video in VLC that has subtitles, the subtitles are shown. If I watch the same video in WMP, the subtitles are not shown. From a quick search it appears I’d have to install extra software to get the SRT subtitles to appear in WMP.

      Phil

      Reply
  6. Lucas

    December 18, 2018 at 11:26 pm

    That was really helpful, thank you. I was just wondering if you could explain to me what is going on at “ActiveCell.Offset(1, 0).Select”, when you have the name of the thing and a dot that means it’s an event right? and I know that 1 means on and 0 off, can you tell me what you did in that line?

    Reply
    • Philip Treacy

      December 19, 2018 at 2:48 pm

      Hi Lucas,

      the . indicates that you using a method (something you can do) or a property of whatever preceded the .

      So for ActiveCell.Offset(1, 0), Offset is a method that moves the focus from the ActiveCell to another cell specified by (1, 0), or whatever values you use there. In my case (1, 0) means move down 1 row and across 0 columns.

      I then use the Select method to select that cell specified by Offset(1, 0)

      Regards

      Phil

      Reply
  7. Duncan Williamson

    December 14, 2018 at 9:42 am

    Thanks for sharing this. As a non ActiveX user until now, I had no idea this was possible.

    I can see many uses for it in my work

    Reply
    • Philip Treacy

      December 14, 2018 at 9:43 am

      Great. It’s always good when we realise new things are possible 🙂

      Reply
  8. Boni Woodland

    December 14, 2018 at 3:56 am

    Thank you So very much for this clear, amazing learning event! I did it -It worked! I am so very jazzed!!!

    Reply
    • Philip Treacy

      December 14, 2018 at 9:39 am

      You’re welcome Boni

      Reply
  9. Victoria

    December 14, 2018 at 2:18 am

    Thank you for the post. Is there a way to use a URL for the video or audio files to send the Excel file to someone to run from their computer?

    Reply
    • Philip Treacy

      December 14, 2018 at 9:42 am

      Hi Victoria,

      Do you mean use a URL to specify the location of a media file, or use a URL to open the Excel file from a web location?

      Regards

      Phil

      Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Current ye@r *

Leave this field empty

Sidebar

More results...

Featured Content

  • 10 Common Excel Mistakes to Avoid
  • Top Excel Functions for Data Analysts
  • Secrets to Building Excel Dashboards in Less Than 15 Minutes
  • Pro Excel Formula Writing Tips
  • Hidden Excel Double-Click Shortcuts
  • Top 10 Intermediate Excel Functions
  • 5 Pro Excel Dashboard Design Tips
  • 5 Excel SUM Function Tricks
  • 239 Excel Keyboard Shortcuts

100 Excel Tips and Tricks eBook

Download Free Tips & Tricks

Subscribe to Our Newsletter

Receive weekly tutorials on Excel, Power Query, Power Pivot, Power BI and More.

We respect your email privacy

239 Excel Keyboard Shortcuts

Download Free PDF

mynda treacy microsoft mvpHi, I'm Mynda Treacy and I run MOTH with my husband, Phil. Through our blog, webinars, YouTube channel and courses we hope we can help you learn Excel, Power Pivot and DAX, Power Query, Power BI, and Excel Dashboards.

Blog Categories

  • Excel
  • Excel Charts
  • Excel Dashboard
  • Excel Formulas
  • Excel PivotTables
  • Excel Shortcuts
  • Excel VBA
  • General Tips
  • Online Training
  • Outlook
  • Power Apps
  • Power Automate
  • Power BI
  • Power Pivot
  • Power Query
microsoft mvp logo
trustpilot excellent rating
Secured by Sucuri Badge
MyOnlineTrainingHub on YouTube Mynda Treacy on Linked In Mynda Treacy on Instagram Mynda Treacy on Twitter Mynda Treacy on Pinterest MyOnlineTrainingHub on Facebook
 

Company

  • About My Online Training Hub
  • Disclosure Statement
  • Frequently Asked Questions
  • Guarantee
  • Privacy Policy
  • Terms & Conditions
  • Testimonials
  • Become an Affiliate

Support

  • Contact
  • Forum
  • Helpdesk – For Technical Issues

Copyright © 2023 · My Online Training Hub · All Rights Reserved. Microsoft and the Microsoft Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. Product names, logos, brands, and other trademarks featured or referred to within this website are the property of their respective trademark holders.