Run - time error '1004'

M

MAX

Hello,

I have a file with a code for blinking text.
At this moment I am entering some data in this file, so I click on macro in
the tool bar to stop the blink texts. The problem is that after I save the
file and come to close the file, a window appears with this error.

Run - time error '1004'
Method 'On Time' of object '_Application' failed.

Continue End Debug Help

Below is the code:


Public RunWhen As Double
Sub StartBlink1()
With ThisWorkbook.Worksheets("Open").Range("A1:A3,B1:B3,C1:C3").Font
If .ColorIndex = 5 Then ' Red Text
.ColorIndex = 49 ' White Text
Else
.ColorIndex = 5 ' Red Text
End If
End With
RunWhen = Now + TimeSerial(0, 0, 1)
Application.OnTime RunWhen, "StartBlink1", , True
End Sub

Sub StopBlink1()

ThisWorkbook.Worksheets("Open").Range("A1:A3,B1:B3,C1:C3").Font.ColorIndex = _
xlColorIndexAutomatic
Application.OnTime RunWhen, "StartBlink1", , False
End Sub
Sub StartBlink2()
With ThisWorkbook.Worksheets("Serie A").Range("AP6,AX6").Font
If .ColorIndex = 3 Then ' Red Text
.ColorIndex = 2 ' White Text
Else
.ColorIndex = 3 ' Red Text
End If
End With
RunWhen = Now + TimeSerial(0, 0, 1)
Application.OnTime RunWhen, "StartBlink2", , True
End Sub

Sub StopBlink2()
ThisWorkbook.Worksheets("Serie A").Range("AP6,AX6").Font.ColorIndex = _
xlColorIndexAutomatic
Application.OnTime RunWhen, "StartBlink2", , False
End Sub


Sub StartBlink3()
With ThisWorkbook.Worksheets("Serie B").Range("AP6,AX6").Font
If .ColorIndex = 3 Then ' Red Text
.ColorIndex = 2 ' White Text
Else
.ColorIndex = 3 ' Red Text
End If
End With
RunWhen = Now + TimeSerial(0, 0, 1)
Application.OnTime RunWhen, "StartBlink3", , True
End Sub

Sub StopBlink3()
ThisWorkbook.Worksheets("Serie B").Range("AP6,AX6").Font.ColorIndex = _
xlColorIndexAutomatic
Application.OnTime RunWhen, "StartBlink3", , False
End Sub
Sub StartBlink4()
With ThisWorkbook.Worksheets("Serie C").Range("AP6,AX6,AP83,AX83").Font
If .ColorIndex = 3 Then ' Red Text
.ColorIndex = 2 ' White Text
Else
.ColorIndex = 3 ' Red Text
End If
End With
RunWhen = Now + TimeSerial(0, 0, 1)
Application.OnTime RunWhen, "StartBlink4", , True
End Sub

Sub StopBlink4()
ThisWorkbook.Worksheets("Serie
C").Range("AP6,AX6,AP83,AX83").Font.ColorIndex = _
xlColorIndexAutomatic
Application.OnTime RunWhen, "StartBlink4", , False
End Sub

Any help please,
Thanks in advance.
 
C

Chip Pearson

A "1004" error is a very generic error that means "something went
wrong but we're not going to tell you what". When you get the error,
click on the Debug button in the message box. That will take you to
the offending line of code. Post that line of code.

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)
 

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

Run Error while protected 1
Protection in VBA. 2
2 codes in one sheet 5
Code Error 3
Two codes in one set. 1
Blinking cells 6
VBA code does not work 7
Run - time error '1004' 1

Top