PC Review


Reply
Thread Tools Rate Thread

Outlook 2000 Appointment start time correction

 
 
Don Mooty
Guest
Posts: n/a
 
      12th Nov 2004
If you ever enter a whole bunch of appointments only to find out you
forgot to change your time zone on your computer, the following will
change all the start times to one hour earlier.

Sub CorrectCalendarStartTimes()
' This code changes the start time of all appointments in a date range
' to one hour earlier unless the body has OK in it.
' allows you to correct appointments with the time zone set
incorrectly
' when the appointments were entered.

Dim oOutApp As Outlook.Application
Dim oNS As Outlook.NameSpace
Dim CalFolder As Outlook.MAPIFolder
Dim CalItems As Outlook.Items
Dim ResItems As Outlook.Items
Dim sFilter As String
Dim iNumRestricted As Integer
Dim itm As Object


Set oOutApp = New Outlook.Application
Set oNS = oOutApp.GetNamespace("MAPI")

' Use the default calendar folder
Set CalFolder = oNS.GetDefaultFolder(olFolderCalendar)

' Get all of the appointments in the folder
Set CalItems = CalFolder.Items

' Sort all of the appointments based on the start time
CalItems.Sort "[Start]"

' Make sure to include all of the recurrences
CalItems.IncludeRecurrences = True

'create the Restrict filter to Limit the date CHANGE TO Yours
sFilter = "[Start] >= '" & Format("11/1/2004 12:00am", _
"ddddd h:nn AMPM") & "'" & " And [End] < '" & _
Format("5/15/2005 12:00am", "ddddd h:nn AMPM") & "'"

' Apply the filter to the collection
Set ResItems = CalItems.Restrict(sFilter)

' This will return 2147843647 if any recurring appointment does not
have an end date
MsgBox ResItems.Count

iNumRestricted = 0

'Loop through the items in the collection. This will not loop
infinitely.
For Each itm In ResItems
iNumRestricted = iNumRestricted + 1
' Doesn't modify anything with the body set to OK
If itm.Body <> "OK" Then
Debug.Print itm.Subject & ": " & itm.Start & " : " & itm.End &
" " & itm.Body
itm.Start = DateAdd("H", -1, itm.Start) ' Adjust to one hour
less
Debug.Print itm.Subject & ": " & itm.Start & " : " & itm.End &
" " & itm.Body
itm.Save
End If
Next

' Display the actual number of appointments in time period.
MsgBox iNumRestricted

Set itm = Nothing
Set ResItems = Nothing
Set CalItems = Nothing
Set CalFolder = Nothing
Set oNS = Nothing
Set oOutApp = Nothing

End Sub



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Outlook 2003 - Calendar - Appointment "Start Time" changes randomly benson.ryan@gmail.com Microsoft Outlook Discussion 0 7th Jun 2007 03:39 PM
Outlook 2007: appointment with end time before start time =?Utf-8?B?UGV0ZXJB?= Microsoft Outlook Calendar 0 24th Apr 2007 01:42 PM
want appointment start time to show in calendar, but not end time =?Utf-8?B?QXJsZW5l?= Microsoft Outlook Calendar 0 18th Oct 2006 04:53 PM
Outlook (wrongly) adds 1 hour to appointment start time colin Microsoft Outlook Discussion 0 26th Mar 2006 08:21 PM
outlook, appointment item, [Start], using date and time Don Microsoft Outlook VBA Programming 2 28th Aug 2003 06:46 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:17 PM.