Introduction
In Outlook 2013, there is a blue line that
highlights the current time in calendar view. However, if you are on
another window, say word or another browser, etc., the time line does not
update and if you look over at your 2nd monitor where the calendar is,
you will see an incorrect time if you are looking at your calendar.
This has been bothering me for a long time and I finally got around to
finding / hacking a fix.
See the following article where others had the same problem.
Background
I got the basic premise of the solution/hack from the following article which provides a timer that runs a piece
of code every minute in Outlook. The trick was to find some Outlook
code that I could insert into the timer function that would update the
time bar. As it turns out, the CalendarView.Save
method does this. One
potential side effect I can think of is if you change your calendar
view but did not intend to save that view, it will get saved every minute
by this hack.
Using the Code
Insert the following code in the ThisOutlookSession
module. You can do this by showing the developer ribbon on the menu. Then selecting the developer ribbon/ Visual Basic on the far left of the ribbon.
In
the application section, insert the following code. You can open up
'ThisOutlookSession
' which opens up the correct source code file. Make
sure the application is selected on the upper left hand drop down box.
Private Sub Application_Quit()
If TimerID <> 0 Then Call DeactivateTimer
End Sub
Private Sub Application_Startup()
MsgBox "Activating the Timer."
Call ActivateTimer(1)
End Sub
Then insert a new module by right clicking on Modules and select Insert/Module. Add the following code in that source file.
Declare Function SetTimer Lib "user32" _
(ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerfunc As Long) As Long
Declare Function KillTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long) As Long
Public TimerID As Long
Public Sub ActivateTimer(ByVal nMinutes As Long)
nMinutes = nMinutes * 1000 * 60
If TimerID <> 0 _
Then Call DeactivateTimer
TimerID = SetTimer(0, 0, nMinutes, AddressOf TriggerTimer)
If TimerID = 0 Then
MsgBox "The timer failed to activate."
End If
End Sub
Public Sub DeactivateTimer()
Dim lSuccess As Long
lSuccess = KillTimer(0, TimerID)
If lSuccess = 0 Then
MsgBox "The timer failed to deactivate."
Else
TimerID = 0
End If
End Sub
Public Sub TriggerTimer(ByVal hwnd As Long, _
ByVal uMsg As Long, ByVal idevent As Long, ByVal Systime As Long)
Dim objView As CalendarView
Dim o As Explorer
For Each o In Application.Explorers
If o.CurrentView.ViewType = olCalendarView Then
Set objView = o.CurrentView
objView.Save
End If
Next o
End Sub
Points of Interest
Note that this code should update multiple calendars if you have
multiple open. I didn't spend a lot of time playing around with the
code in TriggerTimer
to see if another method would update the time bar.
It could be there is a better method to call that doesn't have any
side effects.