Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 175
Default How do I run WMP as an ActiveX object from Excel-VBA

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default How do I run WMP as an ActiveX object from Excel-VBA

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How do I run WMP as an ActiveX object from Excel-VBA


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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 175
Default How do I run WMP as an ActiveX object from Excel-VBA

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to kill an ActiveX object Django Cat[_2_] Excel Discussion (Misc queries) 3 November 8th 07 07:45 PM
Activex component can't create object Naveen New Users to Excel 1 September 4th 07 02:57 PM
429 ActiveX can't create the object CA Excel Programming 2 March 29th 05 03:49 PM
Debug ActiveX object Carlos[_2_] Excel Programming 2 March 5th 04 09:40 PM
activex component can't create object with SAP 6.20 Mark Bigelow Excel Programming 0 July 22nd 03 06:24 PM


All times are GMT +1. The time now is 04:20 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"