Sharing a little programming know-how…

Automating Time Card Entry in Outlook

I’ve got a weekly recurring task to enter my time card information into a intranet web site.  This is pretty mundane stuff and I would often forget to do this when I first started my job.  Thankfully there was a grace period for noobs and I didn’t miss any paychecks.

Eventually the grace period did run out so I set up a recurring task in Outlook to help me remember.  I put the hyperlink to the site in the notes of the task so that I could just click the link to open up the website.  This worked great the first week, but the following week I got no reminder!  What happened?  Well, it turns out when I clicked the link the browser opened and took focus away from the task and I never “circled back” to complete the task.  After the task is marked complete, Outlook generates a new task for the next recurrence.  If it’s not marked complete, it is simply marked as incomplete.  Rather than get a reminder every time I open Outlook for incomplete tasks, which would just get lost in the noise (I have a lot of tabled and pending projects that are “overdue”), I figured I could fix this “quirk” with a little Visual Basic for Applications.

Here’s the code:

Sub TimeCard()
Dim olkTask As Outlook.TaskItem

On Error GoTo ErrHandler:

Set olkTask = ActiveInspector.CurrentItem
'If you name your tasks appropriately, you can filter on the name
'to prevent taking this action on another task
If InStr(olkTask.Subject, "TimeCard")  1 Then
  MsgBox "This is not a 'TimeCard' task!"
  Exit Sub
End If

'Mark it complete so Outlook will generate the next recurrence
olkTask.MarkComplete

'Now go to your website
Set browser = CreateObject("InternetExplorer.Application")
browser.navigate ("http://yourwebsite.net")

ActiveInspector.Close olSave

ErrHandler:
  'Don't care
End Sub

If you have a better way to accomplish this, I’d love to hear about it.  Right now, I just have this macro mapped to a custom toolbar that appears on every task Inspector I open. 😦  I’d like it to just be on the time card tasks, but I did not take the time to figure that out.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.