Rusty Hammond
rusty.hammond at cpiqpc.com
Thu Sep 9 11:12:04 CDT 2010
Rocky, I've had the same issue with traversing through items in the Inbox folder. I had the same solution as you, keep going through it until there's nothing left. One thing I have not tried since moving to Access 2003 (from 97), is linking the Outlook folder as a table in Access and creating a recordset off the linked table to do the processing. It "should" work just like any other Access table. The only reason I haven't tried it is that it works as is, so it's not at the top of the priority list. HTH, Rusty -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Rocky Smolin Sent: Thursday, September 09, 2010 11:03 AM To: 'Access Developers discussion and problem solving' Subject: Re: [AccessD] Deleting Outlook Contacts Steve: " index the contact to be deleted " not sure what you mean. I'm a real amateur at the Outlook object model. Rocky -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Steve Goodhall Sent: Thursday, September 09, 2010 8:55 AM To: Access Developers discussion and problem solving Subject: Re: [AccessD] Deleting Outlook Contacts BODY { font-family:Arial, Helvetica, sans-serif;font-size:12px; }I think your problem is with the way For Each iterates in olContacts. I am out on a customer site and don't have access to all my test beds, but I would suggest that you index the contact to be deleted and count down from the number of items in the olContacts collection. I don't remember whether that index is zero based or one based. I also suggest that you lose the "GoTo" but that's just style. Regards, Steve Goodhall, MSCS, PMP 248-505-5204 On Thu 09/09/10 11:25 AM , "Rocky Smolin" rockysmolin at bchacc.com sent: Dear List: Still struggling with deleting the Outlook contacts. I found that looping through the items and deleting them deleted half so if I started with 1000 contacts at the end of the loop I had 500 left. If I sent the program back through the loop I ended up with 250. etc. So iterating that loop until the Count = 0 works but it's kludgey. Why does it leave half of the contacts behind each time? Here's the code: ' delete all the current contacts Set olContacts = olFolder.Items DeleteAgain: Me.txtProcessing = "Deleting..." & olContacts.Count Me.Repaint For Each olContactItem In olContacts 'MsgBox olContactItem.LastName & ", " & olContactItem.FirstName & " - " & olContacts.Count olContactItem.Delete DoEvents Next Set olContacts = olFolder.Items If olContacts.Count 0 Then GoTo DeleteAgain: Me.txtProcessing displays the number of contacts each time through the big loop. So that's how I know it's only deleting 1/2 each time. When I uncomment the MsgBox line inside the loop, it shows the count going to zero each time the loop executes. But after the loop finishes, there's still 1/2 the contacts left. refreshing the count by Set olContacts = olFolder.Items gives the right count again. Any idea what the heck is going on here? MTIA Rocky -- AccessD mailing list AccessD at databaseadvisors.com [1] http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com Links: ------ [1] mailto:AccessD at databaseadvisors.com -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com ********************************************************************** WARNING: All e-mail sent to and from this address will be received, scanned or otherwise recorded by the CPI Qualified Plan Consultants, Inc. corporate e-mail system and is subject to archival, monitoring or review by, and/or disclosure to, someone other than the recipient. **********************************************************************