Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 92
Default Method 'OnTime' of object'_Application failed

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default Method 'OnTime' of object'_Application failed

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 92
Default Method 'OnTime' of object'_Application failed

Solved

"ordnance1" wrote in message
...
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


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 92
Default Method 'OnTime' of object'_Application failed

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, Procedu=cRunWhat, _
Schedule:=False
On Error GoTo 0
End Sub


"OssieMac" wrote in message
...
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

Reply
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
Method 'MacroOptions' of object'_Application' failed Runtime Error 1004 EagleOne Excel Discussion (Misc queries) 1 October 22nd 14 05:49 PM
Method "Method 'Open' of object 'Workbooks' failed [email protected] Excel Programming 2 June 2nd 10 05:28 PM
ontime method? max Excel Programming 8 February 8th 05 09:04 PM
ontime Method Bill Krone Excel Programming 1 August 12th 04 04:30 PM
Help me with OnTime Method dolegow Excel Programming 1 October 12th 03 01:52 AM


All times are GMT +1. The time now is 11:39 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"