Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Windows Media Player - how to establish references?
Greetings
I have been playing around a little with using VBScript to interact with Windows Media Player's library. For example, here is a script that works fine: '''''''''''''''''''''''''''''''''''''''''''''''''' '' Set mp = CreateObject("WMPlayer.OCX" ) Set mpColl = mp.MediaCollection Set songList = mpColl.getByAttribute("MediaType", "Audio") Set albumDict = CreateObject("Scripting.Dictionary") For i = 0 to songList.Count - 1 Set song = songList.Item(i) albumKey = song.getItemInfo("WM/AlbumArtist") & ", " & song.getItemInfo("Album") If not albumDict.Exists(albumKey) Then albumDict.Add albumKey, "" End If Next albumArray = albumDict.Keys For i = LBound(albumArray) to UBound(AlbumArray) msg = msg & vbCrLf & albumArray(i) Next Msgbox "Albums:" & msg '''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''' I would like to get it to run in VBA , preferably using early bindings and New rather than the CreateObject approach, but every attempt I've used to add the proper references to the project (several references mention Windows Media Player - wmp.dll looks like it *should* work) always throws an error when I try to instantiate a media player object. For example, both Dim mp As WindowsMediaPlayer Set mp = CreateObject("WMPlayer.OCX") and Dim mp As WindowsMediaPlayer Set mp = New WindowsMediaPlayer Throws a run-time error (-2147467259 (80004005): Automation Error, Unspecified Error) Any idea what is happening here? Solutions? I would be satisifed with any way to modify the above script to run in VBA. Thanks in advance -semiopen p.s. Ultimately, I would like to create a spreadsheet that tracks what music I play as a function of time, and would do things like generate a chart showing how much Bach I listened to month to month over a specified time period, so wanting to do it in Excel makes sense (even if it is not a serious app). I could of course write a VBScript to write the data to an Excel workbook which has macros to generate the charts, etc. - but it seems unnatural to split the code between 2 files. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Windows Media Player | Excel Programming | |||
Windows Media Player | Excel Programming | |||
stopping Windows Media Player using VBA | Excel Programming | |||
Media Player versus Windows Media Player | Excel Programming | |||
Media Player versus Windows Media Player | Excel Discussion (Misc queries) |