Click here to Skip to main content
Click here to Skip to main content

Fixing the Time Bar on Outlook 2013 Calendar

, 6 Mar 2014
Rate this:
Please Sign up or sign in to vote.
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.

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

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 '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)

Share

About the Author

bradyguy
Acxiom
United States United States
No Biography provided

Comments and Discussions

 
SuggestionNote: To enable this macro, you must enable macros PinmemberRex Schrader2-Jun-14 7:08 
GeneralMy vote of 5 PinmemberRex Schrader15-May-14 11:25 
Question64 bit version of code Pinmembermicky_r_de9-Apr-14 4:18 
AnswerRe: 64 bit version of code Pinmemberbradyguy16-May-14 5:42 
AnswerRe: 64 bit version of code PinmemberMember 109230253-Jul-14 9:38 
GeneralRe: 64 bit version of code PinmemberKris Walsh14-Aug-14 11:03 
GeneralMessage Automatically Removed PinmemberAsha Roy7-Mar-14 0:51 
Generalchanges look good Pinmemberbradyguy6-Mar-14 11:17 

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

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

| Advertise | Privacy | Mobile
Web04 | 2.8.140827.1 | Last Updated 6 Mar 2014
Article Copyright 2014 by bradyguy
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid