Hey, Scripting Guy! How Can I Schedule an All-Day Event in Microsoft Office Outlook?


Hey, Scripting Guy! Question

Hey, Scripting Guy! How can I schedule an all-day event in Microsoft Office Outlook?

— RL

SpacerHey, Scripting Guy! AnswerScript Center

Hey, RL. Have you ever heard the expression “every dog has its day”? Well, if you haven’t, the idea is that sooner or later everyone will have their moment in the sun, that sooner or later everyone will have a day when things actually go right for a change. That goes for people, that goes for dogs and – lo and behold! – it apparently goes for Scripting Guys as well.

So why is this such a banner day for the Scripting Guys? Well, one of the things we were hoping to do in the next week or two is give people a script that would enable them to add the 2008 Winter Scripting Games to their Outlook calendar; the idea is that this might help us avoid the problems we’ve had in the past two Games, when people show up midway through the competition only to discover that several of the events are already over. Consequently, we’ve been looking for a good excuse to give people this script and explain how it works. And then, out of the blue, we received your question, RL. In other words, it’s true: every dog does have its day!

Note. Well, yes, to tell you the truth we always hoped that when we finally did have our day it would involve something a little more exciting than a question about scheduling all-day events in Microsoft Outlook. On the other hand, considering the way most of our days go, well, we’ll take whatever we can get.

In other words, this is a momentous occasion, an occasion that could be improved only if we actually answered RL’s question. Admittedly, that doesn’t seem very fair; we doubt that Queen Elizabeth has to answer scripting questions when she has her days. On the other hand, that is about the only thing that differentiates the Scripting Guys from Queen Elizabeth. So what the heck; how do we schedule an all-day appointment in Microsoft Outlook? Here’s one way:

Const olAppointmentItem = 1
Const olRecursDaily = 0

Set objOutlook = CreateObject("Outlook.Application")
Set objAppointment = objOutlook.CreateItem(olAppointmentItem)

objAppointment.Start = #2/15/2008#
objAppointment.AllDayEvent = True 
objAppointment.Subject = "2008 Winter Scripting Games"
objAppointment.Body = _
    "2008 Winter Scripting Games, February 15th through March 3rd in the TechNet Script Center."
objAppointment.Location = "http://www.microsoft.com/technet/scriptcenter/funzone/games/default.mspx"
objAppointment.ReminderMinutesBeforeStart = 15
objAppointment.ReminderSet = True

Set objRecurrence = objAppointment.GetRecurrencePattern
objRecurrence.RecurrenceType = olRecursDaily
objRecurrence.PatternStartDate = #2/15/2008#
objRecurrence.PatternEndDate = #3/3/2008#

So there you go: there’s the script. And no, we aren’t going to explain how the thing works; we shouldn’t have to do that as well on our day, should we?

OK, fine. But you know what? This is turning out to be even more of a letdown than we originally thought.

The script starts out by defining a pair of constants, olAppointmentItem and olRecursDaily. We’ll use olAppointmentItem to tell Outlook that we want to schedule an appointment (as opposed to a meeting), and we’ll use olRecursDaily to tell Outlook that this particular appointment recurs on a daily basis. Note that we need to do the latter only because our all-day event (the Scripting Games) takes place over several days. If your all-day event occurs on only a single day then you can leave out the part about creating the constant olRecursDaily. (You can also leave out the part about configuring the recurrence pattern, which we’ll discuss later.)

After we define our constants we create an instance of the Outlook.Application object, then use the CreateItem method to create a new, “blank” appointment. That’s what these two lines of code are for:

Set objOutlook = CreateObject("Outlook.Application")
Set objAppointment = objOutlook.CreateItem(olAppointmentItem)

Once we have this blank appointment our next step is to assign values to the properties of that appointment.

  • Start. This is the start date for our all-day event. Note that we surround the date (February 15, 2008) with pound signs: #2/15/2008#. That helps ensure that the value is seen as a date and not as a string or a mathematical equation. Oh, and because this is an all-day event you don’t need to include a time, just the date.
  • AllDayEvent. As you might expect, this is the key to creating an all-day event: make sure you set the AllDayEvent property to True.
  • Subject. This one is pretty intuitive; it’s just the Subject line for the Outlook appointment. In our case, we’re setting the subject to 2008 Winter Scripting Games.
  • Body. This is another easy one: it’s simply the body of the appointment, the place to put detailed information (at whatever level of detail you consider appropriate) about the appointment.
  • Location. Typically this is the physical location where the event will be held. Because the Scripting Games take place online we entered the Scripting Guys home page instead.
  • ReminderMinutesBeforeStart. We’re giving you 15 minutes warning before the Games begin. If you need more time than that just set the ReminderMinutesBeforeStart value accordingly. For example, suppose you’d like to be notified 2 hours in advance. Two hours equals 120 minutes, so set the ReminderMinutesBeforeStart property to 120. If you don’t want a reminder then don’t bother to set values for either this property or the ReminderSet property.
  • ReminderSet. This actually sets the reminder for the appointment. You must include this property, and set the value to True, if you want to configure a reminder for the event. Setting ReminderMinutesBeforeStart alone won’t do the trick.


If your all-day event takes place on a single day then those are all the properties that you need to configure. As we noted earlier, however, the Scripting Games take place over multiple days. Therefore, we need to execute this block of code as well:

Set objRecurrence = objAppointment.GetRecurrencePattern
objRecurrence.RecurrenceType = olRecursDaily
objRecurrence.PatternStartDate = #2/15/2008#
objRecurrence.PatternEndDate = #3/3/2008#

What we’re doing here is configuring the recurrence pattern for our all-day event, something we can do by using the GetRecurrencePattern method to retrieve the Recurrence object for the appointment. Our all-day event happens each and every day, so we set the RecurrenceType to the constant olRecursDaily. (Are there other recurrence types you can use? Of course there are; see the Outlook VBA Language Reference on MSDN for more information.) The Scripting Games start on February 15, 2008 and end on March 3, 2008; hence we assign those dates to the PatternStartDate and PatternEndDate, respectively.

That’s all we have to do. Well, that and call the Save method to actually add the appointment to our Outlook calendar:


If we open our Outlook calendar we should see the all-day event listed every day from February 15 through March 3:


And if we open one of these appointment occurrences we should see something like this:


Now there are no excuses for coming to the Scripting Games late!

That should do it, RL; thanks for the question, and thanks for giving the Scripting Guys their day. Being the inquisitive type (as well as being the type who’ll look for any excuse to do something other than work), the Scripting Guy who writes this column tried to hunt down the origin of the phrase “every dog has its day.” Among other things, he discovered that the phrase is used (sort of) in William Shakespeare’s Hamlet:

Let Hercules himself do what he may,
The cat will mew and dog will have his day.

Note. It’s probably not our place to criticize Shakespeare, but wouldn’t it sound better if that was “and the dog will have his day”?

We also discovered that the 15th-century Dutch pundit Erasmus reported that, in 405 B.C., the Greek playwright Euripides was killed by a pack of dogs unleashed upon him by one of his rivals. Erasmus thus stated that “Even the most lowly person will at some time get revenge on his oppressor, no matter how powerful the man may be.”

We’re not sure if that’s the actual origin of “every dog has its day.” However, we were definitely interested to see that playwrights have a tendency to unleash packs of dogs on their rivals. For the first time ever, the Scripting Guys are glad we became technical writers rather than playwrights.

And so is the entire world of theater goers.


Discussion is closed.

Feedback usabilla icon