How to write current time to the cell?

J

Jack

When I do:
If oExLogCallTime <> 0 Then moExcelWS.Cells(CurrentRow,
oExLogCallTime).Value = Time
or
If oExLogCallTime <> 0 Then moExcelWS.Cells(CurrentRow,
oExLogCallTime).Value = CStr(Time)

each time when Time is written into sheet the cell displays ##### instead
of digits.
Of course when I resize column the digits appear correctly.

I have noticed that when data written is plain text Excel never displays
#### even if the text is longer then the column width.

My question is how to write that Time so it will be treated as a text?
Jack
 
D

Dave Peterson

If oExLogCallTime <> 0 Then
with moExcelWS.Cells(CurrentRow, oExLogCallTime)
.numberformat="@" 'text
.Value = format(time,"hh:mm:ss")
end with
....

or
.value = "'" & format(time,"hh:mm:ss")
 
Top