how to show time on the caption of excel window?

  • Thread starter Thread starter Guest
  • Start date Start date
Hi
Paste this into a new module and launch PutTime
Sub Update_Caption()
Application.OnTime Now + TimeValue("00:00:01"), "PutTime"
End Sub
Sub PutTime()
Application.Caption = Format(Now, "hh:mm:ss")
Update_Caption
End Sub

HTH
Cordially
Pascal

"show time on the caption of excel window" <show time on the caption of
excel (e-mail address removed)> a écrit dans le message de
news:[email protected]...
 
You can use the caption property of the Application object from a macro.

Application.Caption = Format(Now, "HH:mm")

Hope that helps.

Mike McMaster
 
The OnTime method will eventually fail for this - all it takes is one missed
call when you are editing a cell. Here's an alternative that relies on an
activex wrapper I put around the VB timer that you can get from my site
here:
http://www.enhanceddatasystems.com/ED/Pages/ExcelTimer.htm

The benefit of this is that the timer event does not fire while you are
editing a cell or Excel is busy, but does fire after you have stopped
whatever you are doing. It's also a lot simpler than using Windows API
callbacks.

1. Register the activex control (instructions on the web page)
2. Create a new project, add a form called frmTimer and a module.
3. Add the VBA Timer control to the form.
4. In the module add this

Sub StartClock()
With frmTimer.Timer1
.Interval = 1000
.Enabled = True
End With
'n.b. you do not need to show the form
End Sub

Sub StopClock()
Unload frmTimer
End Sub

5. In the form code, add this

Private Sub Timer1_Timer()
On Error Resume Next
Application.Caption = Format(Now, "HH:MM:SS")
On Error GoTo 0
End Sub

Robin Hammond
www.enhanceddatasystems.com

"show time on the caption of excel window" <show time on the caption of
excel (e-mail address removed)> wrote in message
news:[email protected]...
 

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

Back
Top