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: 386
Default Code Stopped

Hi,

I was given a code which has been working ok until recently, at least as far
as I know but its just stopped working and I dont know why. Nothing has been
altered in the file.

The following section of code shows up as;

Run time error '1004'
Method 'OnTime' of object '_Application' failed

Would anyone know what the issue could be?

VB shows the following line as the issue;
Application.OnTime RunWhen, "SaveAndClose", , False

which is contained with this part of a code
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim oCB As CommandBar
On Error Resume Next
Application.OnTime RunWhen, "SaveAndClose", , False
On Error GoTo 0
For Each oCB In Application.CommandBars
oCB.Enabled = True
Next oCB

Application.DisplayFormulaBar = mFormulaBar

Application.Quit
End Sub

The complete code is

Private mFormulaBar

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim oCB As CommandBar
On Error Resume Next
Application.OnTime RunWhen, "SaveAndClose", , False
On Error GoTo 0
For Each oCB In Application.CommandBars
oCB.Enabled = True
Next oCB

Application.DisplayFormulaBar = mFormulaBar

Application.Quit
End Sub

Private Sub Workbook_Open()
Dim oCB As CommandBar
On Error Resume Next
Application.OnTime RunWhen, "SaveAndClose", , False
On Error GoTo 0

Application.OnKey "%{F11}", "dummy"

For Each oCB In Application.CommandBars
oCB.Enabled = False
Next oCB

mFormulaBar = Application.DisplayFormulaBar
Application.DisplayFormulaBar = False

RunWhen = Now + TimeSerial(0, NUM_MINUTES, 0)
Application.OnTime RunWhen, "SaveAndClose", , True
End Sub





 
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
Can someone please tell me why my code stopped working??? Damil4real Excel Worksheet Functions 0 November 24th 09 10:49 PM
Code Stopped Working Minitman Excel Programming 6 August 27th 08 08:42 PM
Code stopped working chris46521[_22_] Excel Programming 2 August 9th 06 03:05 PM
vb code stopped running Masa Ito[_2_] Excel Programming 1 November 18th 05 04:12 PM
Tab stopped working -- SCOTT-- Excel Programming 0 October 2nd 03 09:14 PM


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

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"