Microsoft KB Archive/254714: Difference between revisions
m (Text replacement - "&" to "&") |
m (Text replacement - """ to """) |
||
Line 75: | Line 75: | ||
# Begin with a clean calendar. | # Begin with a clean calendar. | ||
# On today's date, create four appointments: | # On today's date, create four appointments: "Test1", "Test2", "Test3", and "Test4". | ||
# On yesterday's date, create two daily recurring appointments: | # On yesterday's date, create two daily recurring appointments: "TestR1" and "TestR2". | ||
# Right-click the first occurrence of | # Right-click the first occurrence of "TestR1", click '''Delete''', click '''Delete this one''', and then click '''OK'''. | ||
# In Microsoft Visual Basic 6.0, create a new standard EXE project, remove Form1, and then add a standard Module. | # In Microsoft Visual Basic 6.0, create a new standard EXE project, remove Form1, and then add a standard Module. | ||
# Set a reference to | # Set a reference to "Microsoft Outlook Object Library." | ||
# Paste the following code in the module code window and then execute it: | # Paste the following code in the module code window and then execute it: | ||
Line 95: | Line 95: | ||
Dim sCurrentApptInfo As String | Dim sCurrentApptInfo As String | ||
Set myOLApp = CreateObject( | Set myOLApp = CreateObject("Outlook.Application") | ||
Set oNS = myOLApp.GetNamespace( | Set oNS = myOLApp.GetNamespace("MAPI") | ||
sStartDate = | sStartDate = "#" & Format(Date, "mm/dd/yyyy") & " 12:00 AM#" | ||
sEndDate = | sEndDate = "#" & Format(DateAdd("d", 1, Date), "mm/dd/yyyy") & " 12:00 AM#" | ||
'Today's appointments. | 'Today's appointments. | ||
sRestrict = | sRestrict = "(([start]>='" & sStartDate & "')and ([start]<'" & sEndDate & "'))" | ||
'''' Put this condition if you need Spanning Appointments. | '''' Put this condition if you need Spanning Appointments. | ||
sRestrict = sRestrict & | sRestrict = sRestrict & " or (([start]<='" & sStartDate & "') and ([end]>='" & sStartDate & "'))" | ||
Line 110: | Line 110: | ||
Set myItems = oFolder.Items | Set myItems = oFolder.Items | ||
myItems.Sort | myItems.Sort "[Start]", False | ||
myItems.IncludeRecurrences = True | myItems.IncludeRecurrences = True | ||
Set myItems = myItems.Restrict(sRestrict) | Set myItems = myItems.Restrict(sRestrict) | ||
myItems.Sort | myItems.Sort "[Start]", False | ||
'Print the Appointment info. | 'Print the Appointment info. | ||
For Each oAppt In myItems | For Each oAppt In myItems | ||
sCurrentApptInfo = | sCurrentApptInfo = "Start: " & oAppt.Start & vbCrLf & _ | ||
"End: " & oAppt.End & vbCrLf & _ | |||
"All Day Event: " & oAppt.AllDayEvent & vbCrLf & _ | |||
"Is Recurring: " & oAppt.IsRecurring & vbCrLf & _ | |||
" - " & oAppt.Subject & " (" & oAppt.Location & ")" | |||
Debug.Print sCurrentApptInfo | Debug.Print sCurrentApptInfo | ||
Next | Next | ||
Line 136: | Line 136: | ||
</pre> | </pre> | ||
The results are as follows: | The results are as follows: | ||
* The | * The "TestR1" recurring appointment sorts incorrectly. | ||
* The | * The "TestR2" recurring appointment sorts correctly. | ||
Latest revision as of 13:52, 21 July 2020
Article ID: 254714
Article Last Modified on 3/4/2004
APPLIES TO
- Microsoft Outlook 2000 Standard Edition
This article was previously published under Q254714
SYMPTOMS
The Sort method may sort a filtered appointments collection incorrectly when the first occurrence of a recurring AppointmentItem is also an Exception.
RESOLUTION
To resolve this problem, obtain the latest service pack for Microsoft Office 2000. For additional information, click the following article number to view the article in the Microsoft Knowledge Base:
276367 OFF2000: How to Obtain the Latest Office 2000 Service Pack
STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.
This problem was first corrected in Microsoft Office 2000 Service Pack 3.
MORE INFORMATION
Steps to Reproduce Behavior
- Begin with a clean calendar.
- On today's date, create four appointments: "Test1", "Test2", "Test3", and "Test4".
- On yesterday's date, create two daily recurring appointments: "TestR1" and "TestR2".
- Right-click the first occurrence of "TestR1", click Delete, click Delete this one, and then click OK.
- In Microsoft Visual Basic 6.0, create a new standard EXE project, remove Form1, and then add a standard Module.
- Set a reference to "Microsoft Outlook Object Library."
- Paste the following code in the module code window and then execute it:
Sub Main() Dim oNS As NameSpace Dim myOLApp As Outlook.Application Dim myItems As Outlook.Items Dim oFolder As Outlook.MAPIFolder Dim oAppt As Outlook.AppointmentItem Dim sStartDate As String Dim sEndDate As String Dim sRestrict As String Dim sCurrentApptInfo As String Set myOLApp = CreateObject("Outlook.Application") Set oNS = myOLApp.GetNamespace("MAPI") sStartDate = "#" & Format(Date, "mm/dd/yyyy") & " 12:00 AM#" sEndDate = "#" & Format(DateAdd("d", 1, Date), "mm/dd/yyyy") & " 12:00 AM#" 'Today's appointments. sRestrict = "(([start]>='" & sStartDate & "')and ([start]<'" & sEndDate & "'))" '''' Put this condition if you need Spanning Appointments. sRestrict = sRestrict & " or (([start]<='" & sStartDate & "') and ([end]>='" & sStartDate & "'))" Set oFolder = oNS.GetDefaultFolder(olFolderCalendar) Set myItems = oFolder.Items myItems.Sort "[Start]", False myItems.IncludeRecurrences = True Set myItems = myItems.Restrict(sRestrict) myItems.Sort "[Start]", False 'Print the Appointment info. For Each oAppt In myItems sCurrentApptInfo = "Start: " & oAppt.Start & vbCrLf & _ "End: " & oAppt.End & vbCrLf & _ "All Day Event: " & oAppt.AllDayEvent & vbCrLf & _ "Is Recurring: " & oAppt.IsRecurring & vbCrLf & _ " - " & oAppt.Subject & " (" & oAppt.Location & ")" Debug.Print sCurrentApptInfo Next 'Cleanup. Set oAppt = Nothing Set myItems = Nothing Set oFolder = Nothing Set oNS = Nothing Set myOLApp = Nothing End Sub
The results are as follows:
- The "TestR1" recurring appointment sorts incorrectly.
- The "TestR2" recurring appointment sorts correctly.
Keywords: kbbug kbfix kboutlookobj kbmsg kboffice2000sp3fix kbautomation kbofficexpsp1fix KB254714