I'm trying to embed mp4 videos in my XLSM file, and assign the task to some buttons to play the file when needed.
Private Sub CommandButton2_Click()
WindowsMediaPlayer1.URL = ThisWorkbook.Path & "\video\" & "video1.mp4"
Application.Wait (Now + TimeValue("0:00:02"))
WindowsMediaPlayer1.Controls.Play
End Sub
How to stop media files from autoplay when opening the XLSM file?
Media Player objects have an autostart
property as part of its settings
property. You could set this property to false on startup. In the workbook module put the code:
Private Sub Workbook_Open()
Sheet1.WindowsMediaPlayer1.settings.autoStart = False
End Sub
(With the sheet reference adjusted if needed).