Solved

embed video into excel

Posted on 2014-02-04
3
1,147 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 27

Accepted Solution

by:
MacroShadow earned 500 total points
ID: 39838561
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
ID: 39844115
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 27

Expert Comment

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

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

776 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