Skip to main content

How to play video file from Excel worksheet?

Author: Xiaoyang Last Modified: 2017-01-16

Have you ever tried to play a video file from a worksheet? In this article, I will talk about some interesting tricks for you to play a video file which is stored in your computer from an Excel workbook.

Play a video file from worksheet by setting the properties of Windows Media Player

Play a video file from worksheet by clicking a Command Button


arrow blue right bubble Play a video file from worksheet by setting the properties of Windows Media Player

In Excel, there is a useful control - Windows Media Play can help you to play a video file, please do as follows:

1. Click Developer > Insert > More Controls, see screenshot:

doc play video 1

2. In the More Controls dialog box, scroll and select Windows Media Player option, then click OK button to close the dialog, and then drag the mouse to draw a Windows Media Play object, see screenshot:

doc play video 2

3. Then go to the Properties dialog by clicking Developer > Properties, in the Properties dialog, please do the following operations:

(1.) In the Alphabetic tab, please select True option from the fullScreen field;

(2.) Copy and paste your video file path which should include the file extension into the URL field.

doc play video 3

4. After finishing the above settings, please exit Design mode, and, your specified video is playing now.


arrow blue right bubble Play a video file from worksheet by clicking a Command Button

If you want to play a video file with a command button, when you click the command button, a browse window will pop out to let you choose the video file to play. The following steps may help you:

1. According to the step 1-2 in method 1 to insert the Windows Media Player control, and then go on clicking the Developer > Insert > Command Button to insert a Command Button, see screenshot:

doc play video 4

2. Then right click the Command Button, and choose Properties from the context menu, in the popped out Properties dialog box, type the text Play Video beside the Caption field under Alphabetic tab, see screenshot:

doc play video 5

3. And then close the Properties dialog, then double click the Command Button, and then copy and paste the following VBA code to replace the original code into the Microsoft Visual Basic for Applications window.

VBA code: Play a video file from worksheet:

Private Sub CommandButton1_Click()
    Dim FName As Variant
    FName = Application.GetOpenFilename(FileFilter:="Video Files, *.mp4; *.avi; *.mpeg; *.mts", Title:="Please select a Video File", MultiSelect:=False)
    If FName <> False Then
        WindowsMediaPlayer1.Url = FName
    End If
End Sub

doc play video 6

Note: In the above code, CommandButton1 is the command button name you inserted, and the WindowsMediaPlayer1 is the Windows Media Player name you have inserted. And you can add other video file extensions as you need into the *.mp4; *.avi; *.mpeg; *.mts script.

4. Then save and close the code window, and exit the Design mode, now, when you click the Command Button, a browse window will appear to remind you select the video file you want to play, then click Open button, the specific video file will be played at once. See screenshot:

doc play video 7


Related article:

How to insert or embed youtobe video in Excel worksheet?

Best Office Productivity Tools

ūü§Ė Kutools AI Aide: Revolutionize data analysis based on: Intelligent Execution   |  Generate Code  |  Create Custom Formulas  |  Analyze Data and Generate Charts  |  Invoke Kutools Functions‚Ķ
Popular Features: Find, Highlight or Identify Duplicates   |  Delete Blank Rows   |  Combine Columns or Cells without Losing Data   |   Round without Formula ...
Super Lookup: Multiple Criteria VLookup    Multiple Value VLookup  |   VLookup Across Multiple Sheets   |   Fuzzy Lookup ....
Advanced Drop-down List: Quickly Create Drop Down List   |  Dependent Drop Down List   |  Multi-select Drop Down List ....
Column Manager: Add a Specific Number of Columns  |  Move Columns  |  Toggle Visibility Status of Hidden Columns  |  Compare Ranges & Columns ...
Featured Features: Grid Focus   |  Design View   |   Big Formula Bar    Workbook & Sheet Manager   |  Resource Library (Auto Text)   |  Date Picker   |  Combine Worksheets   |  Encrypt/Decrypt Cells    Send Emails by List   |  Super Filter   |   Special Filter (filter bold/italic/strikethrough...) ...
Top 15 Toolsets12 Text Tools (Add Text, Remove Characters, ...)   |   50+ Chart Types (Gantt Chart, ...)   |   40+ Practical Formulas (Calculate age based on birthday, ...)   |   19 Insertion Tools (Insert QR Code, Insert Picture from Path, ...)   |   12 Conversion Tools (Numbers to Words, Currency Conversion, ...)   |   7 Merge & Split Tools (Advanced Combine Rows, Split Cells, ...)   |   ... and more

Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time.  Click Here to Get The Feature You Need The Most...

Description


Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
Comments (6)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
I have a file of  a number of URLs to music videos.  I'm not sure of the file extensions, because I see only the URLs.  When one video is finished, I want it to go automatically to the next music video, within the range of videos specified. I don't want to have to get up and click the next URL.  I'm not sure how the vba macro could tell the video is finished.  Is there a property that I can read with a function? A do loop should work fine for going through the list of URLs (hyperlinks), but just need to detect when a video is finished.  Can you help?
This comment was minimized by the moderator on the site
This worked for me but what I want to add is the ability to pause the player and also to have a timer event that checks to see if the player has finished so that I can then load the next track, don't really want to do this with playlists as I prefer to keep control of what is playing in my vba. Long story as to why which I can elaborate on if needed but really if you can give a hint as to how to pause and check playing status that will do,Thanks
This comment was minimized by the moderator on the site
This isn't working for me, what do I put in for WindowsMediaPlayer1?? I get that location as my error, I'm not sure what thats supposed to be. I had it have the same name as my file and it didn't bug but it also didn't play a video
This comment was minimized by the moderator on the site
Merci pour les explications.

J'aime bien l'id√©e de lancer une vid√©o en utilisant un bouton dans Excel. Est-ce qu'il est possible, avec un seul bouton, de lancer deux vid√©os diff√©rentes d√©pendamment d'une r√®gle de si. Exemple: Il y a une case dans Excel o√Ļ on doit √©crire un mot donn√©. Lorsqu'on clic sur le bouton, si le mot est exacte, Vid√©o1 se lance. Si le mot est inexacte, vid√©o 2 se lance?
This comment was minimized by the moderator on the site
Where do we search???
This comment was minimized by the moderator on the site
Hi, Calbat,
Could you explain your problem more detailed?
Thank you!
There are no comments posted here yet
Leave your comments
Posting as Guest
Rate this post:
0   Characters
Suggested Locations