ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Code Error (https://www.excelbanter.com/excel-programming/427744-code-error.html)

Max

Code Error
 
I have this code (below) and when I run from Macro a window appears and say
(file could not be found. Check the spelling of the file name, and verify
that the file location is correct). How can I solve this problem.

Thanks

This is the code:

Public RunWhen As Double

Sub StartBlink()
With ThisWorkbook.Worksheets("AAA").Range("AG3").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, "'" & ThisWorkbook.Name & "'!StartBlink3", ,
True
End Sub

Sub StopBlink()
ThisWorkbook.Worksheets("AAA").Range("AG3").Font.C olorIndex = _
xlColorIndexAutomatic
Application.OnTime RunWhen, "'" & ThisWorkbook.Name & "'!StartBlink3", ,
False
End Sub

FSt1

Code Error
 
hi
your main sub is startblink but your ontime is trying to run startblink3.
post startblink3 sub.

Regards
FSt1

"MAX" wrote:

I have this code (below) and when I run from Macro a window appears and say
(file could not be found. Check the spelling of the file name, and verify
that the file location is correct). How can I solve this problem.

Thanks

This is the code:

Public RunWhen As Double

Sub StartBlink()
With ThisWorkbook.Worksheets("AAA").Range("AG3").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, "'" & ThisWorkbook.Name & "'!StartBlink3", ,
True
End Sub

Sub StopBlink()
ThisWorkbook.Worksheets("AAA").Range("AG3").Font.C olorIndex = _
xlColorIndexAutomatic
Application.OnTime RunWhen, "'" & ThisWorkbook.Name & "'!StartBlink3", ,
False
End Sub


JLGWhiz[_2_]

Code Error
 
You should not need the workbook(file) name the procedure is in the same
workbook that calls it.

Public RunWhen As Double

Sub StartBlink()
With ThisWorkbook.Worksheets("AAA").Range("AG3").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 StopBlink()
ThisWorkbook.Worksheets("AAA").Range("AG3").Font.C olorIndex = _
xlColorIndexAutomatic
Application.OnTime RunWhen, "StartBlink3", , False
End Sub


"MAX" wrote in message
...
I have this code (below) and when I run from Macro a window appears and say
(file could not be found. Check the spelling of the file name, and verify
that the file location is correct). How can I solve this problem.

Thanks

This is the code:

Public RunWhen As Double

Sub StartBlink()
With ThisWorkbook.Worksheets("AAA").Range("AG3").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, "'" & ThisWorkbook.Name & "'!StartBlink3",
,
True
End Sub

Sub StopBlink()
ThisWorkbook.Worksheets("AAA").Range("AG3").Font.C olorIndex = _
xlColorIndexAutomatic
Application.OnTime RunWhen, "'" & ThisWorkbook.Name & "'!StartBlink3",
,
False
End Sub




Max

Code Error
 
It was Sub StartBlink3, I had a mistake.

"FSt1" wrote:

hi
your main sub is startblink but your ontime is trying to run startblink3.
post startblink3 sub.

Regards
FSt1

"MAX" wrote:

I have this code (below) and when I run from Macro a window appears and say
(file could not be found. Check the spelling of the file name, and verify
that the file location is correct). How can I solve this problem.

Thanks

This is the code:

Public RunWhen As Double

Sub StartBlink()
With ThisWorkbook.Worksheets("AAA").Range("AG3").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, "'" & ThisWorkbook.Name & "'!StartBlink3", ,
True
End Sub

Sub StopBlink()
ThisWorkbook.Worksheets("AAA").Range("AG3").Font.C olorIndex = _
xlColorIndexAutomatic
Application.OnTime RunWhen, "'" & ThisWorkbook.Name & "'!StartBlink3", ,
False
End Sub



All times are GMT +1. The time now is 05:42 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com