PDA

View Full Version : [SOLVED] Auto close userform when video ends



IvanTs8
01-16-2019, 12:20 PM
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,

23569

Logit
01-17-2019, 08:46 AM
https://stackoverflow.com/questions/18455273/how-to-perform-vba-task-after-media-player-finishes

大灰狼1976
01-18-2019, 01:15 AM
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

大灰狼1976
01-18-2019, 01:46 AM
The picture below is the state here. according to the actual situation, you can modify it yourself.

大灰狼1976
01-18-2019, 01:54 AM
The picture below is the state here. according to the actual situation, you can modify it yourself.
23582

IvanTs8
02-13-2019, 11:27 AM
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