• RyanDev.com

  • Microsoft Outlook Daylight Savings Fix for Calendar

16th February 2008

Microsoft Outlook Daylight Savings Fix for Calendar

There is a setting on a Windows PC to “Automatically adjust clock for daylight saving changes.” If you change this setting your appointments and meetings in your Microsoft Outlook calendar may be moved. Outlook does this intentionally and is not a bug.

Adjust daylight savings automatically

Below is a code sample of how to fix your appointments. 

Attribute VB_Name = “DayLightSavingsFix”Public Sub DayLightSavingsFix()‘***************************************************************************‘This macro will go through all items in a Calendar and change the start time to one hour back.‘It will ignore anything that is not an Appointment or a Meeting‘It will also ignore any all day events.‘This macro will change only items that were created before 1/1/08‘***************************************************************************

Dim CurFolder, MyItems

Dim NumItems As Integer, i As Integer

Dim MyItem As Object

‘Use whichever folder is currently selected

‘This means that you should run this macro with your Calendar folder selected.

Set CurFolder = Application.ActiveExplorer.CurrentFolder

‘Make sure the current folder is a Calendar folder

If CurFolder.DefaultItemType = 1 Then

‘get a handle on the items in the Calendar folder

Set MyItems = CurFolder.Items

NumItems = MyItems.Count

‘loop through all of the Calendar items

For i = 1 To NumItems

On Error Resume Next ‘ignore any errors

Set MyItem = MyItems.Item(i)

If TypeName(MyItem) = “AppointmentItem” Then

‘check to see if item was created before Jan 01 and not an all day event

If DateDiff(”d”, MyItem.CreationTime, “1/1/08 2:00:00 AM”) >= 1 And MyItem.AllDayEvent = False Then

‘change the start time back one hour, end time is automatically adjusted

MyItem.Start = DateAdd(”h”, -1, MyItem.Start)

MyItem.Save

End If

ElseIf TypeName(MyItem) = “MeetingItem” Then

‘check to see if item was created before Jan 1 and not an all day event

If DateDiff(”d”, MyItem.CreationTime, “1/1/08 2:00:00 AM”) >= 1 And MyItem.GetAssociatedAppointment.AllDayEvent = False Then

‘change the start time back one hour, end time is automatically adjusted

MyItem.GetAssociatedAppointment.Start = DateAdd(”h”, -1, MyItem.GetAssociatedAppointment.Start)

MyItem.Save

End If

End If

Next i

MsgBox “Done”

Else

MsgBox “The current folder needs to be a Calendar folder before running this macro.”

End If

‘ Cleanup

Set MyItem = Nothing

Set MyItems = Nothing

Set CurFolder = Nothing

End Sub

To run this code, open Microsoft Outlook and click Tools, Marco, Visual Basic Editor.  Your screen may look something like the following.

Outlook VBA
 

Paste the code into the right side.  Adjust the date for your own needs. 

Note: This code has been tested and confirmed with Microsoft Outlook versions 2000, 2002 and 2003.   The complete code can also be downloaded here.

This entry was posted on Saturday, February 16th, 2008 at 8:34 pm and is filed under Microsoft Office, Microsoft Outlook. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

There are currently 2 responses to “Microsoft Outlook Daylight Savings Fix for Calendar”

Why not let us know what you think by adding your own comment! Your opinion is as valid as anyone elses, so come on... let us know what you think.

  1. 1 On January 11th, 2010, Bathroom radiator said:

    Added to my favourites list and added to my blogroll.

  2. 2 On January 25th, 2010, payday loans said:

    The author of ryandev.com has written an excellent article. You have made your point and there is not much to argue about. It is like the following universal truth that you can not argue with: People frequently smile for no reason when they’re walking up and down the aisles on a flight Thanks for the info.

Leave a Reply

  • Links

  • Calendar

  • February 2012
    S M T W T F S
    « Jan    
     1234
    567891011
    12131415161718
    19202122232425
    26272829