Click here to Skip to main content
15,887,343 members
Articles / Productivity Apps and Services / Microsoft Office
Tip/Trick

Fixing the Time Bar on Outlook 2013 Calendar

Rate me:
Please Sign up or sign in to vote.
5.00/5 (1 vote)
6 Mar 2014CPOL2 min read 42K   2   11
Outlook 2013 does not advance the current time in the calendar view; here is a hack fix.

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.

VB.NET
Private Sub Application_Quit()
  If TimerID <> 0 Then Call DeactivateTimer 'Turn off timer upon quitting **VERY IMPORTANT**
End Sub

Private Sub Application_Startup()
  MsgBox "Activating the Timer."
  Call ActivateTimer(1) 'Set timer to go off every 1 minute
End Sub

Image 1

Then insert a new module by right clicking on Modules and select Insert/Module. Add the following code in that source file.

VB.NET
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 'Need a timer ID to eventually turn off the timer. 
                       'If the timer ID <> 0 then the timer is running

Public Sub ActivateTimer(ByVal nMinutes As Long)
  nMinutes = nMinutes * 1000 * 60 'The SetTimer call accepts milliseconds, so convert to minutes
  If TimerID <> 0 _
  Then Call DeactivateTimer 'Check to see if timer is running before call to SetTimer
  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)
  'MsgBox "The TriggerTimer function has been automatically called!"
   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.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
hCentive
United States United States
https://www.linkedin.com/in/bradychambers

Comments and Discussions

 
QuestionobjView.Save resets my view Pin
Member 1434605229-Apr-19 4:15
Member 1434605229-Apr-19 4:15 
QuestionUpdate for Outlook 2016 Pin
Member 1408490710-Dec-18 20:50
Member 1408490710-Dec-18 20:50 
Questioncompiling error Pin
Member 131731154-May-17 9:14
Member 131731154-May-17 9:14 
SuggestionNote: To enable this macro, you must enable macros Pin
Rex Schrader2-Jun-14 7:08
Rex Schrader2-Jun-14 7:08 
GeneralMy vote of 5 Pin
Rex Schrader15-May-14 11:25
Rex Schrader15-May-14 11:25 
Question64 bit version of code Pin
micky_r_de9-Apr-14 4:18
micky_r_de9-Apr-14 4:18 
AnswerRe: 64 bit version of code Pin
bradyguy16-May-14 5:42
bradyguy16-May-14 5:42 
AnswerRe: 64 bit version of code Pin
Member 109230253-Jul-14 9:38
Member 109230253-Jul-14 9:38 
GeneralRe: 64 bit version of code Pin
Kris Walsh14-Aug-14 11:03
Kris Walsh14-Aug-14 11:03 
Generalchanges look good Pin
bradyguy6-Mar-14 11:17
bradyguy6-Mar-14 11:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.