Solved

embed video into excel

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Introduction This Article is a follow-up to my Mappit! Addin Article (http://www.experts-exchange.com/A_2613.html), it was inspired by an email posting I made to EUSPRIG (http://www.eusprig.org/index.htm), I will briefly cover: 1) An overvie…
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

856 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