ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VBA code does not work (https://www.excelbanter.com/excel-programming/419552-vba-code-does-not-work.html)

Frank Situmorang[_2_]

VBA code does not work
 
Hello,

I have inserted these VBA in the module, but the text in T2 does not blink.
Did I miss something?

Public RunWhen As Double

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

Sub StopBlink()
ThisWorkbook.Worksheets("PO_Line_text").Range("T2" ).Font.ColorIndex = _
xlColorIndexAutomatic
Application.OnTime RunWhen, "'" & ThisWorkbook.Name & "'!StartBlink", ,
False
End Sub

'Then, in the ThisWorkbook code module of the workbook, use code like:

Private Sub Workbook_Open()
StartBlink
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
StopBlink
End Sub

--
H. Frank Situmorang

Bob Phillips[_3_]

VBA code does not work
 
Works fine for me Frank. Did you put the workbook event procedures in
ThisWorkbook?

--
__________________________________
HTH

Bob

"Frank Situmorang" wrote in message
...
Hello,

I have inserted these VBA in the module, but the text in T2 does not
blink.
Did I miss something?

Public RunWhen As Double

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

Sub StopBlink()
ThisWorkbook.Worksheets("PO_Line_text").Range("T2" ).Font.ColorIndex = _
xlColorIndexAutomatic
Application.OnTime RunWhen, "'" & ThisWorkbook.Name & "'!StartBlink", ,
False
End Sub

'Then, in the ThisWorkbook code module of the workbook, use code like:

Private Sub Workbook_Open()
StartBlink
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
StopBlink
End Sub

--
H. Frank Situmorang




Frank Situmorang[_2_]

VBA code does not work
 
No I didn't Phillip, I do not even know where is workbook event procedures .

Could you tell me?

--
H. Frank Situmorang


"Bob Phillips" wrote:

Works fine for me Frank. Did you put the workbook event procedures in
ThisWorkbook?

--
__________________________________
HTH

Bob

"Frank Situmorang" wrote in message
...
Hello,

I have inserted these VBA in the module, but the text in T2 does not
blink.
Did I miss something?

Public RunWhen As Double

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

Sub StopBlink()
ThisWorkbook.Worksheets("PO_Line_text").Range("T2" ).Font.ColorIndex = _
xlColorIndexAutomatic
Application.OnTime RunWhen, "'" & ThisWorkbook.Name & "'!StartBlink", ,
False
End Sub

'Then, in the ThisWorkbook code module of the workbook, use code like:

Private Sub Workbook_Open()
StartBlink
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
StopBlink
End Sub

--
H. Frank Situmorang





Bob Phillips[_3_]

VBA code does not work
 
Near the bottom of the code that you posted you will read


'Then, in the ThisWorkbook code module of the workbook, use code like:


Each VBA project consists of various objects, worksheets, modules and
ThisWorkbook. Copy that code to there.

--
__________________________________
HTH

Bob

"Frank Situmorang" wrote in message
...
No I didn't Phillip, I do not even know where is workbook event procedures
.

Could you tell me?

--
H. Frank Situmorang


"Bob Phillips" wrote:

Works fine for me Frank. Did you put the workbook event procedures in
ThisWorkbook?

--
__________________________________
HTH

Bob

"Frank Situmorang" wrote in message
...
Hello,

I have inserted these VBA in the module, but the text in T2 does not
blink.
Did I miss something?

Public RunWhen As Double

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

Sub StopBlink()
ThisWorkbook.Worksheets("PO_Line_text").Range("T2" ).Font.ColorIndex
= _
xlColorIndexAutomatic
Application.OnTime RunWhen, "'" & ThisWorkbook.Name &
"'!StartBlink", ,
False
End Sub

'Then, in the ThisWorkbook code module of the workbook, use code like:

Private Sub Workbook_Open()
StartBlink
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
StopBlink
End Sub

--
H. Frank Situmorang







Frank Situmorang[_2_]

VBA code does not work
 
I already copied that Phil, exactly like the VBA I mentioned. Maybe somthing
I missed.
Application.OnTime RunWhen, "'" & ThisWorkbook.Name

Waht is this: "'" , should it be filled in the middle?

--
H. Frank Situmorang


"Frank Situmorang" wrote:

Hello,

I have inserted these VBA in the module, but the text in T2 does not blink.
Did I miss something?

Public RunWhen As Double

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

Sub StopBlink()
ThisWorkbook.Worksheets("PO_Line_text").Range("T2" ).Font.ColorIndex = _
xlColorIndexAutomatic
Application.OnTime RunWhen, "'" & ThisWorkbook.Name & "'!StartBlink", ,
False
End Sub

'Then, in the ThisWorkbook code module of the workbook, use code like:

Private Sub Workbook_Open()
StartBlink
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
StopBlink
End Sub

--
H. Frank Situmorang


Mike H

VBA code does not work
 
The code requires no alterations, it's correct. If your confident you've put
all the code where it should be, did you save, close and re-open the workbook?

Mike

"Frank Situmorang" wrote:

I already copied that Phil, exactly like the VBA I mentioned. Maybe somthing
I missed.
Application.OnTime RunWhen, "'" & ThisWorkbook.Name

Waht is this: "'" , should it be filled in the middle?

--
H. Frank Situmorang


"Frank Situmorang" wrote:

Hello,

I have inserted these VBA in the module, but the text in T2 does not blink.
Did I miss something?

Public RunWhen As Double

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

Sub StopBlink()
ThisWorkbook.Worksheets("PO_Line_text").Range("T2" ).Font.ColorIndex = _
xlColorIndexAutomatic
Application.OnTime RunWhen, "'" & ThisWorkbook.Name & "'!StartBlink", ,
False
End Sub

'Then, in the ThisWorkbook code module of the workbook, use code like:

Private Sub Workbook_Open()
StartBlink
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
StopBlink
End Sub

--
H. Frank Situmorang


Frank Situmorang[_2_]

VBA code does not work
 
This is exactly what I copied Mike, and I saved and opened it, but it is
still not blinking. I am using excel2007. So while open my workbook. I go to
toolbar developer than clicked VBA code, then I copied, saved and reopend
still nothing happend

Public RunWhen As Double

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

Sub StopBlink()
ThisWorkbook.Worksheets("PO_Line_text").Range("T2" ).Font.ColorIndex = _
xlColorIndexAutomatic
Application.OnTime RunWhen, "'" & ThisWorkbook.Name & "'!StartBlink", ,
False
End Sub

'Then, in the ThisWorkbook code module of the workbook, use code like:

Private Sub Workbook_Open()
StartBlink
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
StopBlink
End Sub

--
H. Frank Situmorang


"Mike H" wrote:

The code requires no alterations, it's correct. If your confident you've put
all the code where it should be, did you save, close and re-open the workbook?

Mike

"Frank Situmorang" wrote:

I already copied that Phil, exactly like the VBA I mentioned. Maybe somthing
I missed.
Application.OnTime RunWhen, "'" & ThisWorkbook.Name

Waht is this: "'" , should it be filled in the middle?

--
H. Frank Situmorang


"Frank Situmorang" wrote:

Hello,

I have inserted these VBA in the module, but the text in T2 does not blink.
Did I miss something?

Public RunWhen As Double

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

Sub StopBlink()
ThisWorkbook.Worksheets("PO_Line_text").Range("T2" ).Font.ColorIndex = _
xlColorIndexAutomatic
Application.OnTime RunWhen, "'" & ThisWorkbook.Name & "'!StartBlink", ,
False
End Sub

'Then, in the ThisWorkbook code module of the workbook, use code like:

Private Sub Workbook_Open()
StartBlink
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
StopBlink
End Sub

--
H. Frank Situmorang


Frank Situmorang[_2_]

VBA code does not work
 
Thanks to all of you, it works now for me, the 2nd part should have been
copied to the proper place.
--
H. Frank Situmorang


"Mike H" wrote:

The code requires no alterations, it's correct. If your confident you've put
all the code where it should be, did you save, close and re-open the workbook?

Mike

"Frank Situmorang" wrote:

I already copied that Phil, exactly like the VBA I mentioned. Maybe somthing
I missed.
Application.OnTime RunWhen, "'" & ThisWorkbook.Name

Waht is this: "'" , should it be filled in the middle?

--
H. Frank Situmorang


"Frank Situmorang" wrote:

Hello,

I have inserted these VBA in the module, but the text in T2 does not blink.
Did I miss something?

Public RunWhen As Double

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

Sub StopBlink()
ThisWorkbook.Worksheets("PO_Line_text").Range("T2" ).Font.ColorIndex = _
xlColorIndexAutomatic
Application.OnTime RunWhen, "'" & ThisWorkbook.Name & "'!StartBlink", ,
False
End Sub

'Then, in the ThisWorkbook code module of the workbook, use code like:

Private Sub Workbook_Open()
StartBlink
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
StopBlink
End Sub

--
H. Frank Situmorang



All times are GMT +1. The time now is 12:32 PM.

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