Play Videos in Excel with VBA

Post date: Nov 29, 2013 8:52:53 PM

Why Read This?

Add videos to Excel without warning messages like this one.

This applicatoin is about to initialize ActiveX controls that might be unsafe

The "Normal" Way Causes Warnings:

We can add Windows Media Player to Excel like this:

    1. Click Excel's Developer tab

    2. Click Insert option in Controls grouping

    3. Click More Controls icon in the bottom right of the Forms Control Toolbox dialog

    4. Scroll to the bottom of More Controls dialog and select Windows Media Player.

    5. Click and drag the size of the Windows Media Player

    6. Set Properties

    7. And in all likelihood, add VBA code to show/hide the player and load videos

But it makes our Excel workbooks unnecessarily larger and when our workbook opens we get somewhat alarming warnings.

This Way is Better

With very little VBA code, we can play a video from Excel. No references required.

Dim WMP as Object

Set WMP = CreateObject("new:{6BF52A52-394A-11d3-B153-00C04F79FAA6}")

Wmp.OpenPlayer "C:\Users\Public\Videos\Sample Videos\Wildlife.wmv"

This method:

    1. Keeps our workbooks smaller

    2. Runs Windows Media Player outside of Excel

    3. Avoids the nasty warning

Why Add Video to Excel?

    1. Add video help to your applications

    2. Create playlists in Excel and have Excel show them through Windows Media Player