+ Reply to Thread
Results 1 to 2 of 2

Windows Media Player

Hybrid View

  1. #1
    Registered User
    Join Date
    04-25-2013
    Location
    ny
    MS-Off Ver
    Excel 2007
    Posts
    2

    Windows Media Player

    Would someone explain why the following code creates a runtime error

    Private Sub CommandButton1_Click()
    Worksheets("Sheet2").Activate
    Dim wmp7 As WindowsMediaPlayer
    Set wmp7 = CreateObject("WMPlayer.OCX.7")
    End Sub
    The error is
    -----------
    Run-time error"-214467259(80004005)':
    Automation error
    Unspecified error

    I could add the WMP on a worksheet mannually.

    Thanks
    Last edited by Leith Ross; 04-28-2013 at 01:37 PM. Reason: Added Code Tags

  2. #2
    Valued Forum Contributor AlvaroSiza's Avatar
    Join Date
    09-19-2007
    Location
    Staffordshire
    MS-Off Ver
    2007
    Posts
    591

    Re: Windows Media Player

    Does this help any? (obviously position and size were arbitrary to testing)

    Worksheets("Sheet3").Activate
    On Error Resume Next
    ActiveSheet.OLEObjects.Add(ClassType:="WMPlayer.OCX.7", Link:=False, _
            DisplayAsIcon:=False, Left:=336, Top:=91.5, Width:=287.25, Height:= _
            149.25).Select
    End Sub
    BTW - All I did was record the manual placement of the control
    Perhaps it was the Noid who should have avoided me...
    If you are satisfied with my solution click the small star icon on the left. Thanks
    1. Make a copy of your workbook and run the following code on your copy (just in case)
    2. With excel open, press ALT+F11 to open the Visual Basic Editor (VBE). From the "Insert" menu, select "Module".
    3. Paste the code from above into the empty white space. Close the VBE.
    4. From the developer tab, choose "Macros", select the Sub Name, and click "Run".

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1