Application.OnTime stopped working

Z

ZipCurs

Strangely some code I wrote using Application.OnTime stopped working. I
added the Windows Media Player to my library just prior to the failure, but
not until it ran successfully a few time. I am using really simple code so
it seems like it should work, but I have provided it below:

Sub TryIt()
Dim MyStart As Long
Dim RunWhen As Long

RunWhen = Now + TimeSerial(0, 0, 5) ' close 5 seconds from now
MyStart = 200 'This seems to be in seconds

Application.EnableEvents = True
Load UserForm1
UserForm1.Caption = "My File : MyStart - MyFinish"
UserForm1.WindowsMediaPlayer1.settings.autoStart = False

UserForm1.WindowsMediaPlayer1.URL = "C:\myfile.mpg"
UserForm1.WindowsMediaPlayer1.Controls.currentPosition = MyStart 'Jumps
to start location
UserForm1.WindowsMediaPlayer1.Controls.Play
Application.OnTime RunWhen, "EndVideo"
UserForm1.Show
End Sub

Sub EndVideo()
UserForm1.WindowsMediaPlayer1.Controls.stop
UserForm1.WindowsMediaPlayer1.Controls.currentPosition = 200
End Sub

Any help would be appreciated. Note that nearly a piece of code using
Application.OnTime in another workbook works fine.
 
Z

ZipCurs

I am changing my story. Application.OnTime does work when in the workbook,
but only when the Windows Media Player on the UserForm is not involved. When
the Windows Media Player is involved, there is no delay in running the next
routine. Basically, the question is how do I get the delay to work with
running a video on a UserForm. Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Media Player Help 4
Close help 2
If no activity, display a UserForm; 10 seconds later close Workboo 4
Code Stopped 1
Help! Combine Macros 2
2 codes in one sheet 5
Two codes in one set. 1
AutoSave 2

Top