From: ordnance1 on
Can anyone tell me why I get the following error when running the code
below?

Method 'OnTime' of object'_Application failed

I have the following items in a public module

Public Const cRunIntervalSeconds = 30 'Time interval for pulling updated
data from Calendar (in seconds)
Public Const cRunWhat = "TheSub" ' the name of the procedure to run
Public Const SPLASH_MINUTES = 1 'Time interval for the Close Splash screen
(in minutes)
Public Const NUM_MINUTES = 100 'Time interval for closing the workbook(in
minutes)
Public bSELCTIONCHANGE As Boolean
Public Cancel As Boolean
Public RunWhen As Double
Public RunWhenSplash As Boolean



Private Sub Workbook_BeforeClose(Cancel As Boolean)
RunWhenSplash = Now + TimeSerial(0, SPLASH_MINUTES, 0)
Application.OnTime RunWhenSplash, "ShowMySplash", , False
End Sub

From: OssieMac on
Untested but I think that the following variable is incorrectly declared.
Public RunWhenSplash As Boolean

Try the following.
Public RunWhenSplash As Date.

I think that the following line will return False instead of a time when the
variable is declared as Boolean instead of Date
RunWhenSplash = Now + TimeSerial(0, SPLASH_MINUTES, 0)

--
Regards,

OssieMac


"ordnance1" wrote:

> Can anyone tell me why I get the following error when running the code
> below?
>
> Method 'OnTime' of object'_Application failed
>
> I have the following items in a public module
>
> Public Const cRunIntervalSeconds = 30 'Time interval for pulling updated
> data from Calendar (in seconds)
> Public Const cRunWhat = "TheSub" ' the name of the procedure to run
> Public Const SPLASH_MINUTES = 1 'Time interval for the Close Splash screen
> (in minutes)
> Public Const NUM_MINUTES = 100 'Time interval for closing the workbook(in
> minutes)
> Public bSELCTIONCHANGE As Boolean
> Public Cancel As Boolean
> Public RunWhen As Double
> Public RunWhenSplash As Boolean
>
>
>
> Private Sub Workbook_BeforeClose(Cancel As Boolean)
> RunWhenSplash = Now + TimeSerial(0, SPLASH_MINUTES, 0)
> Application.OnTime RunWhenSplash, "ShowMySplash", , False
> End Sub
>
From: ordnance1 on
Solved

"ordnance1" <ordnance1(a)comcast.net> wrote in message
news:E0F6772C-F76F-4DE3-B15A-21569E2E6A40(a)microsoft.com...
> Can anyone tell me why I get the following error when running the code
> below?
>
> Method 'OnTime' of object'_Application failed
>
> I have the following items in a public module
>
> Public Const cRunIntervalSeconds = 30 'Time interval for pulling updated
> data from Calendar (in seconds)
> Public Const cRunWhat = "TheSub" ' the name of the procedure to run
> Public Const SPLASH_MINUTES = 1 'Time interval for the Close Splash screen
> (in minutes)
> Public Const NUM_MINUTES = 100 'Time interval for closing the workbook(in
> minutes)
> Public bSELCTIONCHANGE As Boolean
> Public Cancel As Boolean
> Public RunWhen As Double
> Public RunWhenSplash As Boolean
>
>
>
> Private Sub Workbook_BeforeClose(Cancel As Boolean)
> RunWhenSplash = Now + TimeSerial(0, SPLASH_MINUTES, 0)
> Application.OnTime RunWhenSplash, "ShowMySplash", , False
> End Sub

From: ordnance1 on
Thanks for your reply.

I changed the Workbook_BeforeClose to what you see below. As to your other
comment I changed from Public RunWhenSplash As Boolean, to Public
RunWhenSplash As Double


Private Sub Workbook_BeforeClose(Cancel As Boolean)
On Error Resume Next
Application.OnTime EarliestTime:=RunWhen, Procedure:=cRunWhat, _
Schedule:=False
On Error GoTo 0
End Sub


"OssieMac" <OssieMac(a)discussions.microsoft.com> wrote in message
news:51620FC8-5471-4EA3-8C3E-EE5C84ED5BE2(a)microsoft.com...
> Untested but I think that the following variable is incorrectly declared.
> Public RunWhenSplash As Boolean
>
> Try the following.
> Public RunWhenSplash As Date.
>
> I think that the following line will return False instead of a time when
> the
> variable is declared as Boolean instead of Date
> RunWhenSplash = Now + TimeSerial(0, SPLASH_MINUTES, 0)
>
> --
> Regards,
>
> OssieMac
>
>
> "ordnance1" wrote:
>
>> Can anyone tell me why I get the following error when running the code
>> below?
>>
>> Method 'OnTime' of object'_Application failed
>>
>> I have the following items in a public module
>>
>> Public Const cRunIntervalSeconds = 30 'Time interval for pulling updated
>> data from Calendar (in seconds)
>> Public Const cRunWhat = "TheSub" ' the name of the procedure to run
>> Public Const SPLASH_MINUTES = 1 'Time interval for the Close Splash
>> screen
>> (in minutes)
>> Public Const NUM_MINUTES = 100 'Time interval for closing the workbook(in
>> minutes)
>> Public bSELCTIONCHANGE As Boolean
>> Public Cancel As Boolean
>> Public RunWhen As Double
>> Public RunWhenSplash As Boolean
>>
>>
>>
>> Private Sub Workbook_BeforeClose(Cancel As Boolean)
>> RunWhenSplash = Now + TimeSerial(0, SPLASH_MINUTES, 0)
>> Application.OnTime RunWhenSplash, "ShowMySplash", , False
>> End Sub
>>