Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
What is the syntax to create/run WMP as an ActiveX Object from VBA or
VB-Script? All of the examples I find are in javascript and I cant seem to get it to work in VB. on a discussion thread about Windows Media Player I found this info: You'll need to run it as an ActiveX object in VB, for which you need the ProgID : I think it could be WMPlayer.OCX.7 : It'll be in your registry, search for a value of 6bf52a52-394a-11d3-b153-00c04f79faa6 and look at the ProgID I did look in my resistry and WMPlayer.OCX.7 is the correct ProgId, but how do you bind that so that I can explore the object model using the VB debugging tool inside excel (since this is the only one I am familiar with). I have found the info on how to request access rights to be able to update the WMP objects. But they ALL assume you have already bound the model. There was also an IMPORTS statement that looks like its purpose is to tell VBA about the WMP object model. But I think that is a .net only statement (I'm running Excel2002) and I cant find any info on how it was done before ..net. Link to the object model I'm trying to use: http://msdn.microsoft.com/library/de...collection.asp -- Regards, John |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
In the VBE,
go into tools=References and look for Windows Media Player down toward the bottom. click in the checkbox and close the dialog. Now you should be able to look at it in the object browser -- Regards, Tom Ogilvy "John Keith" wrote in message ... What is the syntax to create/run WMP as an ActiveX Object from VBA or VB-Script? All of the examples I find are in javascript and I cant seem to get it to work in VB. on a discussion thread about Windows Media Player I found this info: You'll need to run it as an ActiveX object in VB, for which you need the ProgID : I think it could be WMPlayer.OCX.7 : It'll be in your registry, search for a value of 6bf52a52-394a-11d3-b153-00c04f79faa6 and look at the ProgID I did look in my resistry and WMPlayer.OCX.7 is the correct ProgId, but how do you bind that so that I can explore the object model using the VB debugging tool inside excel (since this is the only one I am familiar with). I have found the info on how to request access rights to be able to update the WMP objects. But they ALL assume you have already bound the model. There was also an IMPORTS statement that looks like its purpose is to tell VBA about the WMP object model. But I think that is a .net only statement (I'm running Excel2002) and I cant find any info on how it was done before .net. Link to the object model I'm trying to use: http://msdn.microsoft.com/library/de...collection.asp -- Regards, John |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Hello john ,Hello Tom I hope these examples help you Play And Stop *********** Option Explicit Dim Wmp As WindowsMediaPlayer 'activate Windows Media Player reference Sub jouerMediaPlayer() Set Wmp = CreateObject("WMPlayer.OCX.7") Wmp.URL = "C:\Documents and Settings\michel\dossier\myMusic.mid" Wmp.Controls.Play End Sub Sub arreterMediaPlayer() If Wmp Is Nothing Then Exit Sub Wmp.Controls.stop End Sub Duration of musical sequence *********************** Dim ValMin As Double, ValSec As Double, S As Double Set Wmp = CreateObject("WMPlayer.OCX.7") Wmp.URL = "C:\monFichier.mp3" While Wmp.PlayState = 9: DoEvents: Wend S = Wmp.currentMedia.Duration ValMin = Application.WorksheetFunction.RoundDown((S / 60), 0) ValSec = Application.WorksheetFunction.RoundDown(S, 0) - (ValMin * 60) MsgBox Format(ValMin, "00") & ":" & Format(ValSec, "00") regards , miche -- michelxl ----------------------------------------------------------------------- michelxld's Profile: http://www.excelforum.com/member.php...fo&userid=1736 View this thread: http://www.excelforum.com/showthread.php?threadid=39268 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Michael and Tom...
The note about the setting References helped my hunt-and-peck method of exploring VBA and scripting get over that hump. It would have been several more weeks before I would have stumbled on that feature.) Thanks Tom After browsing through the object model features for WMP (and there are a bunch), I was still stuck on how to do the Create.Object for WMP... Thanks for the "live" examples Michael -- Regards, John "michelxld" wrote: Hello john ,Hello Tom I hope these examples help you Play And Stop *********** Option Explicit Dim Wmp As WindowsMediaPlayer 'activate Windows Media Player reference Sub jouerMediaPlayer() Set Wmp = CreateObject("WMPlayer.OCX.7") Wmp.URL = "C:\Documents and Settings\michel\dossier\myMusic.mid" Wmp.Controls.Play End Sub Sub arreterMediaPlayer() If Wmp Is Nothing Then Exit Sub Wmp.Controls.stop End Sub Duration of musical sequence *********************** Dim ValMin As Double, ValSec As Double, S As Double Set Wmp = CreateObject("WMPlayer.OCX.7") Wmp.URL = "C:\monFichier.mp3" While Wmp.PlayState = 9: DoEvents: Wend S = Wmp.currentMedia.Duration ValMin = Application.WorksheetFunction.RoundDown((S / 60), 0) ValSec = Application.WorksheetFunction.RoundDown(S, 0) - (ValMin * 60) MsgBox Format(ValMin, "00") & ":" & Format(ValSec, "00") regards , michel -- michelxld ------------------------------------------------------------------------ michelxld's Profile: http://www.excelforum.com/member.php...o&userid=17367 View this thread: http://www.excelforum.com/showthread...hreadid=392680 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How to kill an ActiveX object | Excel Discussion (Misc queries) | |||
Activex component can't create object | New Users to Excel | |||
429 ActiveX can't create the object | Excel Programming | |||
Debug ActiveX object | Excel Programming | |||
activex component can't create object with SAP 6.20 | Excel Programming |