Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
Real time clock
I have this code to display a real-time clock on a worksheet. However if I do
anything else with in the workbook or worksheet such as type in a cell i get an error message "application defined or error defined error". How do I get rid of this problem? Function GetRealDate() As Date Dim ieApp As Object Dim i As Long Dim strTime As String Dim strHour As String Dim strMinute As String Dim strSecond As String Dim lFirstCom As Long Const sURL = "http://www.time.gov/timezone.cgi?Central/d/-6" Const lElement As Long = 36 Const ieREADYSTATE_COMPLETE As Long = 4 Set ieApp = CreateObject("InternetExplorer.Application") ieApp.navigate sURL Do DoEvents Loop Until ieApp.ReadyState = ieREADYSTATE_COMPLETE strTime = Left(ieApp.Document.all(lElement).innertext, 40) 'store hour strHour = Left(strTime, 2) If Right(strHour, 1) = ":" Then strHour = Left(strTime, 1) End If 'store minute strMinute = Mid(strTime, 4, 2) 'store second 'strSecond = Mid(strTime, 7, 2) Sheets("Actual").Range("I2").Value = strHour Sheets("Actual").Range("J2").Value = strMinute 'Range("C1").Value = strSecond End Function |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
Real time clock
1. the app must be a sub, not a function. A function can't change aribtrary
cell in the worksheet 2. make sure you have loaded any required Library References -- Gary''s Student - gsnu200774 "Jase" wrote: I have this code to display a real-time clock on a worksheet. However if I do anything else with in the workbook or worksheet such as type in a cell i get an error message "application defined or error defined error". How do I get rid of this problem? Function GetRealDate() As Date Dim ieApp As Object Dim i As Long Dim strTime As String Dim strHour As String Dim strMinute As String Dim strSecond As String Dim lFirstCom As Long Const sURL = "http://www.time.gov/timezone.cgi?Central/d/-6" Const lElement As Long = 36 Const ieREADYSTATE_COMPLETE As Long = 4 Set ieApp = CreateObject("InternetExplorer.Application") ieApp.navigate sURL Do DoEvents Loop Until ieApp.ReadyState = ieREADYSTATE_COMPLETE strTime = Left(ieApp.Document.all(lElement).innertext, 40) 'store hour strHour = Left(strTime, 2) If Right(strHour, 1) = ":" Then strHour = Left(strTime, 1) End If 'store minute strMinute = Mid(strTime, 4, 2) 'store second 'strSecond = Mid(strTime, 7, 2) Sheets("Actual").Range("I2").Value = strHour Sheets("Actual").Range("J2").Value = strMinute 'Range("C1").Value = strSecond End Function |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
REAL TIME CLOCK | Excel Discussion (Misc queries) | |||
How do I calculate time in excel (clock in and clock out | Excel Discussion (Misc queries) | |||
Real-time clock in excel | Excel Discussion (Misc queries) | |||
how do i insert a real time clock in excel ? | Excel Discussion (Misc queries) | |||
Change EXCEL Clock to Standard Clock or Military Time | Excel Worksheet Functions |