vbapowerpointactivexwindows-media-player

Problem with Windows Media Player ActiveX control in VBA Powerpoint


it's me and my projects for school again. This time I wanted to insert a video into PowerPoint using file path via WMP ActiveX, so I drew one as follows: (uiMode set to "none")

When the slide show starts, I transfer all data from an Excel file to the presentation, including the paths to the video. Then I hide the WMP with Slide85.WMP.uiMode = "invisible".

When the time comes, I want the WMP to appear at the original size that i drawn and the linked video to play, so I used these codes:

Slide85.WMP_TT.uiMode = "none"
Slide85.WMP_TT.URL = "C:\inetpub\wwwroot\TT2.mp4"
Slide85.WMP_TT.Controls.Play

Already muted the video by changing the settings in the Properties tab.

Then the result came out like this:

enter image description here

The video still plays, but only with sound, which is impossible because I muted the control. No visual images is shown from the video, and the control's dimensions changes too.

As of now I cannot think of any causes to this problem. Please help me, I'd be very grateful.


Solution

  • As mentioned on this Microsoft help page, you have to set height and width parameters in code for the player to reserve the space when triggering uiMode="invisible": Player.uiMode

    As an alternative, you can draw the size as you have done, then use VBA to hide or show it on the slide with code like this:

    Sub HideWMP()
        Dim oSlide As Slide
        Dim oShape As Shape
        For Each oSlide In ActivePresentation.Slides
            For Each oShape In oSlide.Shapes
                If oShape.Type = msoOLEControlObject Then
                    oShape.Visible = msoTrue
                End If
            Next oShape
        Next oSlide
    End Sub