View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Malone[_3_] Malone[_3_] is offline
external usenet poster
 
Posts: 1
Default stopping Windows Media Player using VBA

I've been trying to write some code which will start playing an audio file and then stop after a certain number of seconds. I've tried this:-

sub testcode ()

Dim wmp as WindowsMediaPlayer

Set wmp = New WindowsMediaPlayer

wmp.URL = "C:\audio\test.mp3"

wmp openPlayer (wmp.URL)

Application.Wait Now() + TimeSerial(0, 0, 10)

wmp.Controls.stop

End Sub

It opens the player ok and plays the file but then it doesn't stop after 10 sec.

wmp.playState tells me it is stopped - but the player keeps going. Is wmp.Controls.stop the wrong command?

I'm not too experienced with this sort of thing so I may be making a really silly mistake. Can anyone tell me what it is?