+ Reply to Thread
Results 1 to 6 of 6

Please help to Insert video in "Do Loop" VBA code in excel

Hybrid View

  1. #1
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,083

    Re: Please help to Insert video in "Do Loop" VBA code in excel

    Point 1. This seems to work. Adjust file names and timings as required.

    Option Explicit
    
    Sub Macro1()
    
    Dim WMP As Object
    Set WMP = CreateObject("new:{6BF52A52-394A-11d3-B153-00C04F79FAA6}")
    
    Const FileName1 As String = "S:\test\abc.mp4"
    Const FileName2 As String = "S:\test\abc.mp4"
    
    Application.DisplayAlerts = False
    
    Do
    
    Dim i As Integer
    i = i + 1   ' get out of jail; adjust as required
    If i > 1 Then Exit Do
        
        Sheets("Sheet1").Select
        Range("A2").Select
        
        Application.Wait Now() + TimeValue("0:00:05")
             
        Sheets("Sheet2").Select
        Range("A2").Select
    
        Application.Wait Now() + TimeValue("0:00:05")
    
        Sheets("Sheet3").Select
        Range("A3").Select
    
        Application.Wait Now() + TimeValue("0:00:05")
    
        Sheets("Sheet4").Select
        Range("B3").Select
        
        'insert code here to play video (19 sec), video is on S:\test\abc.mp4
        Debug.Print "first"
        WMP.OpenPlayer FileName1
    
        Application.Wait Now() + TimeValue("0:00:19")
        
        Debug.Print "second"
        WMP.OpenPlayer FileName2
    
        Application.Wait Now() + TimeValue("0:00:19")
        
        'Shell ("taskkill /f /im wmplayer.exe")
        Shell "CMD /C TASKKILL /IM wmplayer.exe"
        
        Debug.Print "end"
    
    Loop
    
    Application.DisplayAlerts = True
       
    End Sub
    Point 2. Nothing I have tried works. I Googled this: excel vba make windows media player open full screen. Unfortunately, none of the suggestions helped although I could be missing something.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  2. #2
    Registered User
    Join Date
    02-15-2021
    Location
    New Zealand
    MS-Off Ver
    Office365
    Posts
    7

    Re: Please help to Insert video in "Do Loop" VBA code in excel

    Thank you so much for you help

+ 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. Replies: 3
    Last Post: 05-02-2018, 08:03 AM
  2. Replies: 1
    Last Post: 04-01-2014, 03:21 AM
  3. Macro Error with code "Range("A65536").End(xlUp).EntireRow.Insert"
    By lukasj13 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-30-2010, 08:48 PM
  4. Excel 2002 "Protect Sheet", but Allow "Insert Comments"?
    By VP Safe in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 10:05 AM
  5. Excel 2002 "Protect Sheet", but Allow "Insert Comments"?
    By VP Safe in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 03:05 AM
  6. [SOLVED] Excel 2002 "Protect Sheet", but Allow "Insert Comments"?
    By VP Safe in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-05-2005, 11:05 PM
  7. Excel 2002 "Protect Sheet", but Allow "Insert Comments"?
    By VP Safe in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-05-2005, 10:05 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