+ Reply to Thread
Results 1 to 11 of 11

Excel VBA Macro to start a local video (WMP) within worksheet using a shortcut

  1. #1
    Registered User
    Join Date
    10-11-2020
    Location
    Stoke
    MS-Off Ver
    2019
    Posts
    11

    Excel VBA Macro to start a local video (WMP) within worksheet using a shortcut

    I am a novice to Excel VBA code but this is what I've learned / done so far. The code below is a module initiated in Excel by a key shortcut. Ctrl Shift T. It runs the video within the worksheet as required, but with a small screen. I'd like to add to the code to launch the video full screen and when finished close the Windows Media Player and return to the same point in the worksheet. I wonder if anyone knows how to do this please?


    Sub Title_Vid1()
    Dim WMP As Object

    Set WMP = CreateObject("new:{6BF52A52-394A-11d3-B153-00C04F79FAA6}")

    WMP.openPlayer "C:\Users\User1\Teenage_Dream.mp4"


    End Sub

  2. #2
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Excel VBA Macro to start a local video (WMP) within worksheet using a shortcut

    I suggest a look and see here
    https://www.extendoffice.com/documen...lay-video.html
    ---
    Hans
    "IT" Always crosses your path!
    May the (vba) code be with you... if it isn't; start debugging!
    If you like my answer, Click the * below to say thank-you

  3. #3
    Registered User
    Join Date
    10-11-2020
    Location
    Stoke
    MS-Off Ver
    2019
    Posts
    11

    Re: Excel VBA Macro to start a local video (WMP) within worksheet using a shortcut

    Thank you. Yes I'd read that page but once you set the Properties to fullscreen and play the video, it resets to Fullscreen False!

  4. #4
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Excel VBA Macro to start a local video (WMP) within worksheet using a shortcut

    It's full screen the moment you play it, that's what you were looking for; no?

  5. #5
    Registered User
    Join Date
    10-11-2020
    Location
    Stoke
    MS-Off Ver
    2019
    Posts
    11

    Re: Excel VBA Macro to start a local video (WMP) within worksheet using a shortcut

    Yes, but do not wish to have to reset the properties every play.

  6. #6
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Excel VBA Macro to start a local video (WMP) within worksheet using a shortcut

    That's what macros are for, you do that with a macro.
    I thought that that much was clear.

  7. #7
    Registered User
    Join Date
    10-11-2020
    Location
    Stoke
    MS-Off Ver
    2019
    Posts
    11

    Re: Excel VBA Macro to start a local video (WMP) within worksheet using a shortcut

    Thank you, I think we were talking at cross purposes. I have got the Fullscreen code working now BUT, after the video ends, the WMP stays on the screen! Can I hide close or minimise it within the VBA?
    Here is my latest code:

    Sub Play_Title_Vid()
    '
    '
    ' Keyboard Shortcut: Ctrl+Shift+T
    '


    Title_Vid = """C:\Users\User1\1-Active\0-General\3-Leisure\Quizes\Quiz_Master\Videos\Test01.mp4"""

    Shell "C:\Program Files\Windows Media Player\wmplayer /fullscreen /new /play /close " & Title_Vid

    End Sub

  8. #8
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,525

    Re: Excel VBA Macro to start a local video (WMP) within worksheet using a shortcut

    Hi Richard,

    I've not done this but see if this page helps.

    Please also put code tags i.e. [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] around any code you post. Thanks.

    Regards,

    Robert
    ____________________________________________
    Please ensure you mark your thread as Solved once it is. Click here to see how
    If this post helps, please don't forget to say thanks by clicking the star icon in the bottom left-hand corner of my post

  9. #9
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Excel VBA Macro to start a local video (WMP) within worksheet using a shortcut

    I think you should attach a sample file.
    One thing I noticed in your code, you have hard-coded the path the video file, that's a NO-NO when you program anything, what if someone else wants to use the file? HE/She will not have the same filepath.
    You either use the thisworkbook.path if it's in the same folder or else add a snippet to select the folder where the videos are stored.
    Rule of thumb: NEVER hard-code things like paths, printer names etc in any code no matter in which language you're programming

  10. #10
    Registered User
    Join Date
    10-11-2020
    Location
    Stoke
    MS-Off Ver
    2019
    Posts
    11

    Re: Excel VBA Macro to start a local video (WMP) within worksheet using a shortcut

    Hi Trevor, thank you so much for your help. That website is the best I've seen so far.

  11. #11
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,525

    Re: Excel VBA Macro to start a local video (WMP) within worksheet using a shortcut

    Glad to hear it helped and thanks for rep

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Auto run Embedded video file on start up. help
    By Johnny247 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-30-2019, 02:04 PM
  2. How to make an inputted video always start as playing fullscreened?
    By Taz97 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-25-2018, 11:54 AM
  3. Replies: 1
    Last Post: 07-16-2016, 12:26 PM
  4. Replies: 0
    Last Post: 03-01-2016, 01:13 AM
  5. Sendkeys Macro will not start with keyboard shortcut
    By chelly55555 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 08-19-2014, 11:34 AM
  6. Excel, is there a shortcut to add to start and end of a formula?
    By TakeMeAway in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 05-18-2013, 04:35 AM
  7. Replies: 1
    Last Post: 08-09-2011, 01:06 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1