Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

embed video into excel

Posted on 2014-02-04
3
Medium Priority
?
1,381 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 28

Accepted Solution

by:
MacroShadow earned 2000 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 28

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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Windows Explorer let you handle zip folders nearly as any other folder: Copy, move, change, and delete, etc. In VBA you can also handle normal files and folders, but zip folders takes a little more - and that you'll find here.
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 demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

971 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