Creating Custom Reminders


 

I was on Twitter last night looking for tweets about Outlook when I stumbled across this one.

https://twitter.com/NOLAJake/status/332661039940386816

Here’s my reply and Jake’s follow-up.

Creating some reminders is easy enough, so I put a solution together for Jake. Here’s how it works.

When Jake runs the macro it will prompt him for the name of a client. Once he enters that the macro will create the three reminders Jake wants. The macro includes options allowing Jake to control the type of reminder (task or calendar event), the reminder’s subject line, the category the reminders will belong to (Jake can color code them if he wants), the number of minutes before the event’s start time to show the reminder (if Jake sets the type to Event), the time to display the reminders (if Jake set the type to Task), and the length of the event on the calendar (if Jake sets the type to Event).

Instructions.

Follow these instructions to add the code to Outlook.

  1. Start Outlook
  2. Press ALT + F11 to open the Visual Basic Editor
  3. If not already expanded, expand Microsoft Office Outlook Objects
  4. If not already expanded, expand Modules
  5. Select an existing module (e.g. Module1) by double-clicking on it or create a new module by right-clicking Modules and selecting InsertModule.
  6. Copy the code from the code snippet box and paste it into the right-hand pane of Outlook’s VB Editor window
  7. Click the diskette icon on the toolbar to save the changes
  8. Close the VB Editor
Sub CreateReminders()
    '--> Create some constants
    'On the next line set the reminder type to either Event (to put the reminders on your calendar) or Task (to add the reminders to your task list).
    Const REM_TYPE = "Task"
    'On the next line edit the default reminder subject line.  The client's name will be appended to the subject.
    Const REM_SUBJECT = "Call Client - "
    'On the next line edit the name of the category to be assigned to all reminders
    Const REM_CATEGORY = "Client Calls"
    'On the next line edit the number of minutes before the start of the of the appointment to show the reminder.  Only used if REM_TYPE is set to Event.
    Const REM_MINUTES = 5
    'On the next line edit the time reminders will be shown.  Only used if the REM_TYPE is set to Task.
    Const REM_TIME = #9:00:00 AM#
    'On the next line edit the default length of the appointment in minutes.  Only used if the REM_TYPE is set to Event.
    Const REM_DURATION = 15
    Const SCRIPT_NAME = "Create Reminders"
    
    '--> Create some variables
    Dim olkApt As Outlook.AppointmentItem, olkTsk As Outlook.TaskItem, strClient As String, intCnt As Integer, bolCreated As Boolean
    
    '--> Initialize some variables
    bolCreated = True
    
    '--> Main routine
    'Get the client's name.
    strClient = InputBox("Enter the name of the client to contact.", SCRIPT_NAME)
    'Was a name entered?
    If strClient = "" Then
        'No
        MsgBox "Operation cancelled.  You must enter a client's name for this macro to work.", vbCritical + vbOKOnly, SCRIPT_NAME
    Else
        'Yes
        'Create the three reminders: 14 days, 1 month, and 3 months
        For intCnt = 1 To 3
            Select Case REM_TYPE
                'Create events
                Case "Event"
                    Set olkApt = Application.CreateItem(olAppointmentItem)
                    olkApt.Subject = REM_SUBJECT & strClient
                    Select Case intCnt
                        Case 1
                            olkApt.Start = DateAdd("d", 14, Date) & " " & REM_TIME
                        Case 2
                            olkApt.Start = DateAdd("m", 1, Date) & " " & REM_TIME
                        Case 3
                            olkApt.Start = DateAdd("m", 3, Date) & " " & REM_TIME
                    End Select
                    olkApt.Duration = REM_DURATION
                    olkApt.ReminderSet = True
                    olkApt.ReminderMinutesBeforeStart = REM_MINUTES
                    olkApt.Categories = REM_CATEGORY
                    olkApt.Save
                'Create tasks
                Case "Task"
                    Set olkTsk = Application.CreateItem(olTaskItem)
                    olkTsk.Subject = REM_SUBJECT & strClient
                    Select Case intCnt
                        Case 1
                            olkTsk.DueDate = DateAdd("d", 14, Now)
                        Case 2
                            olkTsk.DueDate = DateAdd("m", 1, Now)
                        Case 3
                            olkTsk.DueDate = DateAdd("m", 3, Now)
                    End Select
                    olkTsk.ReminderSet = True
                    olkTsk.ReminderTime = olkTsk.DueDate & " " & REM_TIME
                    olkTsk.Categories = REM_CATEGORY
                    olkTsk.Save
                'REM_TYPE has an invalid value
                Case Else
                    bolCreated = False
                    Exit For
            End Select
        Next
        If bolCreated Then
            MsgBox "I created the reminders.", vbInformation + vbOKOnly, SCRIPT_NAME
        Else
            MsgBox "Operation cancelled.  The reminder type is invalid.  Valid types are 'Event' and 'Task'.", vbCritical + vbOKOnly, SCRIPT_NAME
        End If
    End If
    
    '--> Clean up
    Set olkApt = Nothing
    Set olkTsk = Nothing
End Sub

Adding Buttons to Run the Macro with a Single Click.

If Jake wants to run the macro with a single click, then he’ll need to add a toolbar button in Outlook 2007 or a button on the Quick Access Toolbar (QAT) for Outlook 2010.

Outlook 2007. Follow these instructions to add a toolbar button that runs the macro.

Outlook 2010. Follow these instructions to add the macro to the QAT.

Advertisements

6 comments on “Creating Custom Reminders

    • Hi, mannagod7.

      Yes, a similar process could create an hourly task between a starting and ending time each day. Something like the code below. It will create a task each hour between 9:00am and 5:00pm daily. You would run it once each morning to create the tasks.

      Sub CreateReminders()
          '--> Create some constants
          'On the next line edit the default reminder subject line.
          Const REM_SUBJECT = "Call Client"
          'On the next line edit the name of the category to be assigned to all reminders
          Const REM_CATEGORY = "Client Calls"
          'On the next line edit the time reminders will begin.
          Const REM_START = #9:00:00 AM#
          'On the next line edit the time reminders will end.
          Const REM_END = #5:00:00 PM#
          Const SCRIPT_NAME = "Create Reminders"
           
          '--> Create some variables
          Dim olkTsk As Outlook.TaskItem, datCur As Date, datEnd As Date
           
          '--> Main routine
          datCur = Date & " " & REM_START
          datEnd = Date & " " & REM_END
          Do While datCur <= datEnd
              Set olkTsk = Application.CreateItem(olTaskItem)
              With olkTsk
                  .Subject = REM_SUBJECT & strClient
                  .ReminderSet = True
                  .ReminderTime = datCur
                  .Categories = REM_CATEGORY
                  .Save
              End With
              datCur = DateAdd("h", 1, datCur)
          Loop
           
          '--> Clean up
          Set olkApt = Nothing
          Set olkTsk = Nothing
      End Sub
      
  1. Interesting. Alternately, what about a creating an event and then with the event selected, a macro to duplicate it?

    • Mike,

      That’s doable, but I’d have to understand more about how you’d want it to work.

    • Not for me, just another take on the original problem. Instead of asking for all the information up front, let the user fill out an event the normal way, then just duplicate that event.

    • Mike,

      Good idea. Thanks. I’ll see about putting together a revision that does it that way.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s