You might want to try using the Items.Restrict method to filter the items by date. See
http://www.outlookcode.com/d/finddate.htm
Also note that ItemAdd is an event, not a method.
--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx
"Tony WONG" <(E-Mail Removed)> wrote in message news:%(E-Mail Removed)...
>i have the following code to sort out the records into a text file.
> ********************
> Set KKK = objfolder.Items
> KKK.Sort "Start", False
> For Each Item In KKK
> If Item.Class = 26 Then
> If Item.Start >= Now Or Item.End >= Now Then
> With webfile
> .writeline Item.Subject
> End With
> End If
> End If
> Next
> ********************
> there are too many records in the folder now. i wish to change the code to
> cut out the records first and then sort them in ascending order. i tried
> out the following code but fail to item into items code. Could you give me
> a hand or hints to do it? Thanks a lot.
>
> above method : sort in ascending order first, and then cut the records out
> of the date range.
>
> below method : cut the records out of the date range, and then assign them
> in a object, and then sort the items in the object in ascending order.
>
> i think i have technical difficulties in assigned the new object at code ROW
> 5
>
> **********************************
> Set JJJ = objfolder.Items
> For Each Item In objfolder.Items
> If Item.Class = 26 Then
> If Item.Start >= Now Or Item.End >= Now Then
> JJJ.ItemAdd Item
> End If
> End If
> Next
> JJJ.Sort "Start", False
> For Each Item In JJJ
> With webfile
> .writeline Item.Subject
> End With
> Next
> *******************************
>
>