Solved

embed video into excel

Posted on 2014-02-04
3
1,050 Views
Last Modified: 2014-02-26
Hi,

I know how to embed a ms video player and get it to play a video.  However, what I would like to do, is once button is clicked it brings up file browser to select video to be played.

Also, has control buttons for play pause, and when MARK is clicked it starts a timer until its clicked again and the places the values into a sell, and repeats process if required.

Also, the video box currently shoots to size of video, I would like to be able to force this to a defined size.

How to do this?
0
Comment
Question by:DemonForce
  • 2
3 Comments
 
LVL 26

Accepted Solution

by:
MacroShadow earned 500 total points
Comment Utility
You've actually asked several questions here:
1. How to code a sub-procedure that will browse for a media file and then play the selected file in a WindowsMediaPlayer ActiveX control.
2. How to create a timer in vba and write result to cell.
3. How to force a WindowsMediaPlayer ActiveX control to retain its size regardless of the video size.

As for the answers:

1. Add a command button to your sheet, add the following code to the click event:
Private Sub CommandButton1_Click()
    Dim FName As Variant
    FName = Application.GetOpenFilename(FileFilter:="Video Files, *.mp4; *.avi; *.mpeg", Title:="Select a Video File", MultiSelect:=False)
    If FName <> False Then
        WindowsMediaPlayer1.URL = FName
    End If
End Sub

Open in new window

where WindowsMediaPlayer1 is the name of the control

3. To pre determine the size of the control you can add code like this:
Private Sub CommandButton1_Click()
    Dim FName As Variant
    FName = Application.GetOpenFilename(FileFilter:="Video Files, *.mp4; *.avi; *.mpeg", Title:="Select a Video File", MultiSelect:=False)
    If FName <> False Then
        With WindowsMediaPlayer1
            .Width = 120
            .Height = 120
            .Left = 10
            .Top = 10
            .URL = FName
        End With
    End If
End Sub

Open in new window


As far as your second question goes, it is unrelated to the first one, and should be asked in a separate question.
0
 

Author Comment

by:DemonForce
Comment Utility
Hi

Thanks, seem to be getting an error with code, have inserted wma player and references are correct, but not seem to like anything in the with statement
0
 
LVL 26

Expert Comment

by:MacroShadow
Comment Utility
WindowsMediaPlayer1 is the name of your wmp control, if yours is named differently, change it accordingly.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now