LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 103
Default Errors Closing Userform

Hello,

I have been working for some time to automate opening a video or audio file
& limiting play to the period between a start and finish time. I have
decided to focus on a wmp.dll based object placed on a UserForm and use code
on the UserForm to limit and control the play. I am working in Excel 2007 on
a Windows XP systems. The code is below:

Private Sub WindowsMediaPlayer1_PlayStateChange(ByVal NewState As Long)
Dim MyStart As Long
Dim MyEnd As Long
Dim MyFile As String

MyFile = Range("B2")
MyStart = Range("B3")
MyEnd = Range("B4")

DoEvents

UserForm1.Enabled = True

Recheck:

If WindowsMediaPlayer1.playState = wmppsStopped Then
WindowsMediaPlayer1.Controls.currentPosition = MyStart
DoEvents
ElseIf WindowsMediaPlayer1.playState = wmppsPaused Then
DoEvents
ElseIf WindowsMediaPlayer1.playState = wmppsPlaying Then
Do
If WindowsMediaPlayer1.playState < wmppsPlaying Then GoTo Recheck
DoEvents
Loop Until WindowsMediaPlayer1.Controls.currentPosition MyEnd

WindowsMediaPlayer1.Controls.Stop
End If

DoEvents

End Sub

The code works fine, except when the UserForm is closed with the "X" in the
upper right hand corner of the UserForm. I get the following error if the
media is actively playing and the developer window is still locked:

Run-time error '-2147417848 (80010108)':
Automation error
The object invoked has disconnected from its clients.

If it is not obvious, the macro is in a Do loop at that time. I am ok with
not being able to close the UserForm if the media is running, but I do need
to have user access to the WMP UI enabled. (i.e. Userform1.Enabled=False
will not work)

Any thoughts about how to resolve this error would be greatly appreciated.
Thank you in advance.

ZipCurs

 
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
Userform errors goaljohnbill Excel Programming 3 November 13th 08 06:18 PM
Closing a db file getting errors don Excel Programming 0 May 26th 06 01:09 AM
Closing UserForm Keri Excel Programming 3 October 25th 05 07:31 PM
closing a userform mangesh_yadav[_50_] Excel Programming 5 August 31st 04 02:26 PM
Propogating errors after closing Workbook. Randy MacDonald Excel Programming 2 January 7th 04 12:31 PM


All times are GMT +1. The time now is 06:38 AM.

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"