Windows Media Player Size in vba userform

6.3k views Asked by At

When WMP is running in a VBA UserForm it sizes automatically based on clip size and resolution, irrespective of Width and Height properties being set programmatically. I need the video to have a fixed size. The following code does nothing:

With UserForm1.WindowsMediaPlayer1
    .URL = "C:\AnyVideo.mp4"
    .Controls.Play
    .stretchToFit = True
    .Width = 500
    .Height = 300
    .Top = 0
    .Left = 0
End With

The following code does work but makes the video jumpy at the beginning - starts playing at its own size, then jumps to the new size, not a professional look.

With UserForm1.WindowsMediaPlayer1
    .URL = "C:\AnyVideo.mp4"
    .Controls.Play
End With

Timer_1 = Timer + 1

Do While Timer < Timer_1
    DoEvents
Loop

With UserForm1.WindowsMediaPlayer1
    .stretchToFit = True
    .Width = 600
    .Height = 300
    .Top = 0
    .Left = 0
End With

I've looked around and have found nothing to explain what's going on or to solve this. Anybody can help?

1

There are 1 answers

0
Karpak On

Click on the WindowsMediaPlayer1 control and Select the custom property. You will see the "Windows Media Player Properties" Window. Uncheck the "Auto Start" option. That should resolve this problem.

Just this is enough. you no need to do any other options to be set. It won't flicker or won't look jumpy etc.

You can now size the WindowsMediaPlayer1 control based on whatever the size you want in the design mode itself. If you still want, you can also do the same through code as well. It should work as you expect, after you uncheck the above option.