Setting a Default Appointment Length in Outlook


Back in January of this year I responded to a question on Quora. Tom, the author of the question, asked

Can the default meeting duration be customized in Microsoft Outlook?
For example, can we default to 25 minute meetings instead of 30, and 55 minutes instead of 60 – enterprise wide?

As Tom had already discovered, Outlook does allow you to set a default meeting length, but with a limited set of choices. You’re only options are 5, 6, 10, 15. 30, or 60 minutes. There’s another hitch to this too. The meeting length option is controlled by changing the time scale on the calendar. Changing the time scale not only changes the default appointment length, it also changes the appearance of the calendar in both the Day and Week views. Changing the setting will only change the duration of appointments created in the Day and Week views. Appointments created outside of those views default to 30 minutes.

I explained this to Tom, adding that a scripted solution could solve this for him. Tom declined and that was the end of the question until yesterday when a new participant, Phillip, posted to the question. Phillip wants a scripted solution and asked where he could find one. Here’s Phillip’s answer.

This solution is almost identical to the one I used in my last post “Changing the Behavior of Appointments“. It works by watching for new Outlook windows opening on screen. When it sees one the code checks to see if the item in the window is an appointment. If it is, the code then tests to see if the item is a new appointment. This is an important test because we don’t want to change the length of appointments already on the calendar. Having determined that the item is new the last step in the process is to set the length of the meeting to the default duration.

Hopefully this solution is just what Phillip is looking for. He didn’t indicate the version of Outlook he’s using, so I’m taking the liberty of assuming it’s 2010. The instructions are geared toward that version.

The solution comes in two parts.

Part 1.

Follow these instructions to add this 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. Right-click on Class Modules, select Insert > Class Module
  5. In the Properties panel click on Name and enter clsMeeting
  6. Copy the code from the Code Snippet box and paste it into the right-hand pane of Outlook’s VB Editor window
  7. Edit the code as needed. I included a comment line where changes can/need to be made
  8. Click the diskette icon on the toolbar to save the changes
'On the next line edit the default meeting length (in minutes) 
Const DEFAULT_LENGTH = 45

Private WithEvents olkIns As Outlook.Inspectors

Private Sub Class_Initialize()
    Set olkIns = Application.Inspectors
End Sub

Private Sub Class_Terminate()
    Set olkIns = Nothing
End Sub

Private Sub olkIns_NewInspector(ByVal Inspector As Inspector)
    Dim olkApt As Outlook.AppointmentItem
    If Inspector.CurrentItem.Class = olAppointment Then
        Set olkApt = Inspector.CurrentItem
        With olkApt
            If .CreationTime = #1/1/4501# Then
                .Duration = DEFAULT_LENGTH
            End If
        End With
    End If
    Set olkApt = Nothing
End Sub

Part 2.

Follow these instructions to add this code to Outlook.

  1. If not already expanded, expand Microsoft Office Outlook Objects and click on ThisOutlookSession
  2. Copy the code from the Code Snippet box and paste it into the right-hand pane of Outlook’s VB Editor window
  3. Edit the code as needed. I included comment lines wherever something needs to or can change
  4. Click the diskette icon on the toolbar to save the changes
  5. Close the VB Editor
  6. Click File and select Options
  7. When the Outlook Options dialog appears click Trust Center then click the Trust Center Settings button
  8. Click Macro Settings
  9. Select either of the two bottom settings (i.e. “Notifications for all macros” or “Enable all macros (not recommended; potentially dangerous code can run)”. The choice of which to chose is up to you. If you select “Notifications”, then you’ll be prompted at times to enable macros. If you pick “Enable all” then there’s a chance that a malicious macro could run. It’s a question of how much risk you want to assume.
  10. Click Ok until the dialog-boxes have all closed
  11. Close Outlook
  12. Start Outlook. Outlook will display a dialog-box warning that ThisOutlookSession contains macros and asking if you want to allow them to run. Say yes.
Private objMeeting As clsMeeting

Private Sub Application_Quit()
    Set objMeeting = Nothing
End Sub

Private Sub Application_Startup()
    Set objMeeting = New clsMeeting
End Sub

Revisions.

  • Revision 1

In a comment to this post Brad Baber notes that when he changes a new appointment from “All day event” to a regular appointment the duration defined in the script by DEFAULT_LENGTH doesn’t get applied. For example, Brad creates a new appointment by double-clicking on his calendar in monthly view. The appointment created by this action defaults to an all day event. What Brad has discovered is that unchecking the “All day event” box results in the appointment length changing from all day to the default length set in Outlook as opposed to the default length set in this script. Brad wants to know if there’s a way to have the default length defined by the script applied in this circumstance.

The good news for Brad is that the answer is “yes”. With a modification the script can monitor a newly created appointment watching to see if the “All day event” box is checked/unchecked and take action accordingly. There’s a caveat though. If Brad opens any other item between the time he creates and saves the new appointment (e.g. he creates a new appointment, then opens and reads a message before switching back to and completing the appointment), then this solution will fail. Without going into a lot of detail, this is a result of tracking open items. This solution only tracks one open item. A proper, more complete solution would have to track all open items and that would require a lot more code.

I explained this limitation to Brad who is okay with it. If you decide to use this solution, then keep this limitation in mind. Do not open any other Outlook items between the time you create and save a new appointment. In other words, create the appointment, fill it out, and save it without opening any other Outlook items. By “items” I mean emails, contacts, tasks, notes, or other appointments.

To use this revision replace the code in part 1 of the original post with the version below. The code in part 2 of the original is unchanged.

'On the next line edit the default meeting length (in minutes)
Const DEFAULT_LENGTH = 45

Private WithEvents olkIns As Outlook.Inspectors, _
        WithEvents olkApt As Outlook.AppointmentItem

Private Sub Class_Initialize()
    Set olkIns = Application.Inspectors
End Sub

Private Sub Class_Terminate()
    Set olkIns = Nothing
End Sub

Private Sub olkApt_PropertyChange(ByVal Name As String)
    If Name = "AllDayEvent" Then
        If olkApt.AllDayEvent = False Then
            olkApt.Duration = DEFAULT_LENGTH
        End If
    End If
End Sub

Private Sub olkApt_Unload()
    Set olkApt = Nothing
End Sub

Private Sub olkIns_NewInspector(ByVal Inspector As Inspector)
    If Inspector.CurrentItem.Class = olAppointment Then
        Set olkApt = Inspector.CurrentItem
        With olkApt
            If .CreationTime = #1/1/4501# Then
                .Duration = DEFAULT_LENGTH
            End If
        End With
    End If
End Sub
Advertisements

51 comments on “Setting a Default Appointment Length in Outlook

    • Hi, Richard.

      Line #5 is a blank line. Are you sure the copy and paste worked properly? Please compare the code as it appears in Outlook to what you see in the original post.

    • Thanks for the reply, David. By line 5 I mean the one starting with “WithEvents olkApt”. The compiler stops with the identifier “olkApt” highlighted. My copy of the code looks pretty faithful, but obviously I have missed something…

    • Richard,

      Got it. You’re talking about the code in the revision. Are the comma and underscore in place at the end of line 4?

    • David – your suggestion about deleting everything at ends of lines was spot on. Thanks! The macro now works as advertised with Outlook 2016 for me.
      Apparently, there were invisible characters between code statements that were messing things up for the compiler. Very strange. I had even tried pasting the code copied from the OP into Notepad, and then copy/pasting this into the VB editor, but got the same bad result.
      (Somehow my previous reply migrated to the next thread.)

  1. The revision is not working for me in Outlook 2016. I have macros enabled and followed all instructions. I also create my appts by clicking on a day in Month View and the All Day Event box remains checked by default. I guess I’m just looking for the All Day Event box to be unchecked by default so I can quickly change the start time without clicking the checkbox first.

    • Nothing happens at all. Well, everything still functions as it always did. The Untitled-Event dialog box opens when I double-click a day, but the All Day Event is still checked and the hours greyed out. I’m familiar with Excel VBA but this is the first time I’ve tried using code in Outlook. I don’t think I’ve done anything wrong as far as your instructions go. Is it possible it just doesn’t work in 2016?

    • No error msg. It just behaves as it always did (All day event is checked). I know the code is working in Week View because I set the default time to 50 minutes and that’s what I get when I dbl click a time slot. It seems to me the code in the revision only sets the duration if All Day Event is False and does nothing if All Day Event is True (It is true when you dbl click a day in Month View). Can we simply add an “Else” statement that clears the checkbox?

    • Hi, milkytech.

      I just tested to make sure and the code works properly in Outlook 2016. I created appointments in each calendar view and each time it correctly set the meeting length to the default length. However, in the month view it did leave the “All day event” option set. To alter that behavior, replace the olkIns_NewInspector in part 1 of the code with the version below.

      Private Sub olkIns_NewInspector(ByVal Inspector As Inspector)
          If Inspector.CurrentItem.Class = olAppointment Then
              Set olkApt = Inspector.CurrentItem
              With olkApt
                  If .CreationTime = #1/1/4501# Then
                      .Duration = DEFAULT_LENGTH
                      .AllDayEvent = False
                  End If
              End With
          End If
      End Sub
      
    • Sweet, that did it! I had tried a similar solution (below) with no success but I guess I put it in the wrong sub:

      Private Sub olkApt_PropertyChange(ByVal Name As String)
          If Name = "AllDayEvent" Then
              If olkApt.AllDayEvent = True Then
                  olkApt.Duration = DEFAULT_LENGTH
                  olkApt.AllDayEvent = False
              End If
          End If
      End Sub
    • Then I don’t know. The best suggestion I can make is to delete everything after the underscore until the next line down comes up to that line. Once that happens, hit return to bump line 5 back to line 5.

  2. Working ! Thanks a lot ! (Outlook 2007, not exactly the same paths for the different functions, but with two or three remaining neurons, that makes the job).

    • How do I reply to the original post? I followed your instructions today. I am running Outlook 2013 and need 45 minute appointment increments. It seems to work however every time I open Outlook I get a pop up that says MS has identified a potential security concern and wants me to either enable or disable macros. In order to use the code I have to enable the macros. But then everything runs/loads slow. Anyone else have this issue? And is it going to ask me to enable macros every time I open Outlook till the end of time? You would think that for the cost of the MS programs they would make these types of things easier.

      Anyway, not even sure if you will see or respond so thanks in advance.

      By the way I took a screen shot of the warning pop up but don’t see how to insert it.

      file:///C:/Users/Michelle/Desktop/macros.jpg

    • Michelle,

      I have to approve each comment before it appears. I’ve just approved both of your comments.

  3. Hi Mr Lee,

    This is Bram from Belgium. Is it possible to do this on a mac, if yes, would you mind explaining it to me?

    kind regards

    • Hi, Bram.

      I’m afraid I cannot answer the question. I’m not a Mac user and have no idea if it’s possible on that platform. Sorry, I’m strictly a PC guy.

  4. I have just made a small program that allows you to change the meeting length of your outlook appointments to suit your own liking.

    (The idea was to allow 4 minutes of transport time to get from one meeting to another, since that was a problem where I used to work)

    http://4minutes.ecomerc.com/

    For novice computer users it might be easier that hacking the outlook VBA, and easier to deploy company wide.

  5. Pingback: Outlook Calendar Default Appointment Duration | OutlookRecoveryGuide.org

  6. Thanks Dave,
    I created a new form for selecting room (getting rooms from my database), can I call the new form on Rooms button click?
    I am using outlook 2013
    Thanks

    • You’re welcome, Pierre.

      Not in any way that I know of. You can read more about custom meeting request forms here. The only way I can think of is to create a form that emulates a meeting request form. You could add a button to it that would use your rooms database.

  7. Pingback: Outlook Appointments Default To Private | OutlookRecoveryGuide.org

  8. Thank you for the thourough guide, for someone like me who has a lot of experience with computers and programming but none with visual studio or microsoft software, this type of step-by-step instructions are greatly appreciated.

    Anyway, I’ve been trying to install the script on outlook 2013 without success. It gives me a “Expected user-defined type, not project” when compiling. Some research has shown me that this is probably due to missing libraries.
    Thus, my question is, what libraries do the script depend on?

  9. Hi David,
    This is very good – we are switching in our organization from 60mins to 45mins meetings, so very handy tool.
    Thanks for the good work!

    Perhaps an improvement option could be to automatically check if there is an overlapping meeting with a 15 min (in the case of 45min.) later ending time (eg ending at 11h15) and automatically adjust the starting time to the ending time of the overlapping meeting. So if you enter a new appointment at 11h00 it would be set to 11h15 starting time.

    Kind regards,
    Peter

    • Hi, Peter.

      Thanks, and you’re welcome.

      That’s an interesting idea. The only question I have is would it annoy the end user? Annoy in the sense that the end user chose the starting time, presumably knowing that it overlapped. Would they find it annoying to have the code change the starting time on them?

  10. This is a great tip, thanks for writing it up. Another addition could be to add a new constant called START_OFFSET at the very top, and then add the line

    .Start = DateAdd(“n”, START_OFFSET, .Start)

    just before the point where you set the duration – this would then allow for meetings to start just after the hour – eg start at 5 minutes past, duration 45 mins.

    • Thanks, Ewan. That’s an interesting idea. To avoid confusion, I wonder if you might want to include logic that tests the appointment’s start time to see if it starts on the hour and only applies the offset if it does? My thought is that applying the offset to all appointments might be confusing (e.g. if the appointment’s start time was 1:15 the code would change it to 1:20).

  11. This is absolutely great! Thank you!

    One little detail, though: when i enter a new appt, the ‘All day event’ box is checked and the default time says midnight to 1am. So your macro is working at this point.

    But when I uncheck ‘All day event’, it switches start time to 8:00 and end time to 8:30.

    Is there any way to get the DEFAULT_LENGTH to apply there as well?

    • Thanks and you’re welcome, Brad!

      Yes, I can make it work that way, but with a caveat. For the solution to work you won’t be able to open any other Outlook item while you have the new appointment open. Will that work for you?

    • Yeah that will definitely work. I’m new to VBA, but I like to think that I’m a fairly good programmer. my familiarity with the Microsoft environment (objects, events, …) is lacking. Is there maybe an event for when that box is unchecked or something?

    • Sort of. There’s an event for when a property of the underlying item (i.e. the appointment) is changed. That event passes the name of the changed property. I’ll alter the code to trap events for the open item and look for property changes. If the change is to the property that’s connected to that box, then I’ll set the duration. These are relatively small changes. I’ll try and have a revision up by tomorrow morning.

    • There is another issue with all day event. If you enter an all day event, it does not get saved unless you un-check and re-check the ‘all day event’ mark. Outlook then resets the time, and will save the event.
      In any other case, you THINK you have closed and saved it but nothing actually gets entered in the agenda. So it really changes default behavior!

    • My solution to come by the all day issue of not saving, is simply to test for allday event and skip changing times. I also added a delayed start time in this solution – to allow for travel time

      code below, paste as described above for the class module (part 1)
      ‘———————————————————————————————
      Option Explicit
      ‘Set Default Appointment Length
      Const DEFAULT_LENGTH = 50 ‘default meeting length (in minutes)
      Const DEFAULT_DELAY = 10 ‘default start delay time in minutes

      Private WithEvents olkIns As Outlook.Inspectors, _
      WithEvents olkApt As Outlook.AppointmentItem

      Private Sub Class_Initialize()
      Set olkIns = Application.Inspectors
      End Sub

      Private Sub Class_Terminate()
      Set olkIns = Nothing
      End Sub

      Private Sub olkIns_NewInspector(ByVal Inspector As Inspector)
      If Inspector.CurrentItem.Class = olAppointment Then
      Set olkApt = Inspector.CurrentItem
      With olkApt
      If Not .AllDayEvent Then
      If .CreationTime = #1/1/4501# Then
      .Duration = DEFAULT_LENGTH
      .Start = .Start + (DEFAULT_DELAY / 24 / 60) ‘convert days to decimal minutes
      End If
      End If
      End With
      End If
      End Sub
      ‘———————————————————————————————————–

  12. Thanks Dave, that’s great, very helpful. I hope to be able to propagate this within my own organization, but it may be challenging to have people work with macros.

    So one follow-up. Is there any reasonable way to create some sort of default “buffer” time (say 5 min) so that the dropdown choices when you modify the end time are not 30, 60, 90, etc. but 25, 55, 85, etc?

    • Happy Holidays, David.

      Not only is there no “reasonable” way there’s no way I know of to modify them at all. The values are built into the form and the first page of the appointment form cannot be changed. That rules out creating a custom form with your own set of values.

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