Consulting

Results 1 to 6 of 6

Thread: Auto close userform when video ends

  1. #1
    VBAX Regular
    Joined
    Dec 2018
    Posts
    11
    Location

    Auto close userform when video ends

    Hello,
    I have a userform that has multiple command buttons for test instructions. When a user clicks on one of the command buttons, a new userform opens and plays a instruction video. when the video ends, the user has to click Esc to exit full screen and close that userform by 'X'. is it possible to have a code that automatically closes the userform when video ends/stops?

    The video starts to play automatically when the userform opens. The video file is .mp4 stored on local drive.
    Attached is a image if it might help understand what is going on.
    Thanks,


  2. #2

  3. #3
    VBAX Mentor 大灰狼1976's Avatar
    Joined
    Dec 2018
    Location
    SuZhou China
    Posts
    479
    Location
    Private Sub WindowsMediaPlayer1_StatusChange()
    Dim s$
    s = WindowsMediaPlayer1.Status
    Debug.Print s
    If s = "??" Or s = "??" Then Unload Me  'According to the result of debug.print, fill in the quotation mark yourself. 
    'The version of the operating system is different, and the property string is also different. 
    End Sub

  4. #4
    VBAX Mentor 大灰狼1976's Avatar
    Joined
    Dec 2018
    Location
    SuZhou China
    Posts
    479
    Location
    The picture below is the state here. according to the actual situation, you can modify it yourself.
    Attached Images Attached Images

  5. #5
    VBAX Mentor 大灰狼1976's Avatar
    Joined
    Dec 2018
    Location
    SuZhou China
    Posts
    479
    Location
    The picture below is the state here. according to the actual situation, you can modify it yourself.
    test.jpg

  6. #6
    VBAX Regular
    Joined
    Dec 2018
    Posts
    11
    Location
    Hello all, I have been away for a while with no time to write back. Thank you both for the solutions provided. I have found this to do the work.
    Private Sub WindowsMediaPlayer1_StatusChange()
    If WindowsMediaPlayer1.Status = "Stopped" Then Unload Me
    End Sub

Posting Permissions

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