Consulting

Results 1 to 2 of 2

Thread: Windows media player on excel spreadsheet

  1. #1

    Windows media player on excel spreadsheet

    Hello,

    I have a worksheet with a media player on it. I would like to be able to play a video without opening a separate instance of WMP. Someone suggested the following code which i tried to alter to my specifics but I am getting no association between the code and the player. The buttons for play, etc. are still all greyed out. does anyone have any idea what I am missing? thank you

    [VBA] Option Explicit
    Sub TryPlayer()

    Dim oSh As Worksheet
    Dim oWmp As WindowsMediaPlayer

    Dim o As Object
    Dim v As Variant

    '*****************************************
    'Get a reference to the Media Player.
    'Awkward, but couldn't find a better way.
    '*****************************************
    Set oSh = Worksheets("Sheet1")
    oSh.Activate
    oSh.Cells(1, 1).Activate

    For Each v In oSh.OLEObjects
    If v.progID Like "WMPlayer*" Then
    Set oWmp =
    v.Object
    Exit For
    End If
    Next v

    If IsNull(oWmp) Then
    MsgBox "Couldn't find WindowsMediaPlayer"
    Exit Sub
    End If


    '*****************************************
    'Play chimes.
    '*****************************************
    oWmp.URL = "C:\WINNT\Media\chimes.wav"
    End Sub
    [/VBA]

  2. #2
    VBAX Contributor Ivan F Moala's Avatar
    Joined
    May 2004
    Location
    Auckland New Zealand
    Posts
    185
    Location
    This worked for for
    The Embeded media player is Private to the container it is in = the Activesheet
    Hence my code references the Sheet Code name = Sheet1
    Try substituing for this.

    Dim WMP As WindowsMediaPlayer
    
        Set WMP = Sheet1.WindowsMediaPlayer1
        WMP.URL = "C:\WINDOWS\Media\chimes.wav"
    Kind Regards,
    Ivan F Moala From the City of Sails

Posting Permissions

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