Open a webpage when a Task reminder fires

Last reviewed on September 22, 2013

This week's entry in my Lazy Programmer series is a variation of last week's macro that sends an email when Appointment reminders fire.

This VBA sample opens a web page in Internet Explorer after a reminder fires, using the URL entered into a Task's Subject field. To avoid firing with every reminder, it looks at the message class and exits if not a Task reminder. It then checks the Category field. If the Category is "Open Page", the macro opens Internet Explorer and navigates to the URL in the Subject field.

Outlook 2003 users can also use the method described in Scheduling a Recurring Message.

This code could easily be changed to run when an appointment reminder fires, such as to open an online meeting url.

Open a webpage using a reminder

Set macro security to off or to 'always ask'. You may need to restart Outlook for the lower macro security settings to kick in.

To use:

  1. Open the VBA editor using Alt+F11
  2. Expand the VBA project
  3. Double click on ThisOutlookSession to open it
  4. Paste the code into ThisOutlookSession

Return to Outlook and create your task:

  1. Create a new task, entering a web address in the Subject field.
  2. Create a category called "Open Page" and assign it to the task.
  3. Set the reminder for the desired date and time then save and close.

Private Sub Application_Reminder(ByVal Item As Object)
  Dim strURL As String
  Dim oApp As Object
  Set oApp = CreateObject("InternetExplorer.Application")

If Item.MessageClass <> "IPM.Task" Then
  Exit Sub
End If

If Item.Categories <> "Open Page" Then
  Exit Sub
End If

strURL = Item.Subject
oApp.navigate (strURL)
oApp.Visible = True

'wait for page to load before passing the web URL
Do While oApp.Busy
End Sub

Open other files types

To open other file types, you need to reference the correct application and change the code that opens the file to the method used by the other application.

For example, to open an Excel workbook, you'll need to create the Excel.Application instead of InternetExplorer.Application, then open the workbook. Remove the DoEvents block, since we don't need to wait for Excel to open.

Set oApp = CreateObject("Excel.Application")

oApp.Workbooks.Open FileName:=strURL
oApp.Visible = True

Opening some files, such as text files in Notepad, will use a Shell command. Remove the oApp lines and use just the Shell command.

Shell ("Notepad.exe " & strURL), vbNormalFocus

Batch (*.bat) can be opened using just the file path:

Shell (strURL), vbNormalFocus


If you create a recurring task, remember to mark the task complete, instead of dismissing it.

To use this with an appointment, change If Item.MessageClass <> "IPM.Task" Then to If Item.MessageClass <> "IPM.Appointment" Then. If you want a neater entry on your calendar, put the url in the Location field and replace strURL = Item.Subject with strURL = Item.Location

If you want to use tasks to open different items, such as a web page using one task and an Excel workbook using another, you need to wrap the code in If statements:

If Item.Categories = "Open Web" Then
'do whatever
End If
If Item.Categories = "Open Excel" Then
'do whatever
End If

Written by

Diane Poremsky
A Microsoft Outlook Most Valuable Professional (MVP) since 1999, Diane is the author of several books, including Outlook 2013 Absolute Beginners Book. She also created video training CDs and online training classes for Microsoft Outlook. You can find her helping people online in Outlook Forums as well as in the Microsoft Answers and TechNet forums.

Please post long or more complicated questions at Outlookforums.

2 responses to “Open a webpage when a Task reminder fires”

  1. Bruno V

    Hello Diane, I came to this page after having received today's (May 8) Outlook Daily Tips. In the newsletter you say that "with a little tweaking, you could use it to open almost any file type". I would like to use this to open (a) specific Excel file(s) triggered by a task reminder. What would be the code for doing this, assuming the file path is something like M:/My Data/My Dropbox/Project A/filename01.xlsx (or xslm)? I uinderstand this is an Outlook tips websiter and newsletter, but if you could point me in the right direction, it would be awesome. Bruno

Leave a Reply

If the Post Coment button disappears, press your Tab key.