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.
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.