Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Outlook / Programming VBA / July 2005

Tip: Looking for answers? Try searching our database.

Looking for code on resolving duplicates

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Chris Kinata - 28 Jul 2005 23:20 GMT
Hi again,

Mentioned in another post that I'm working on a method
for converting entries sent from a web mailto form into Contacts.

I've been looking for many hours for some simple open-source
VBA code that doesn't delete duplicate contacts, but
attempts to merge missing information into whatever is
the "best" instance of that contact. Am wanting the
code rather than an add-in, because I'll want to modify it.

Using the emailAddress fields as primary keys, would
I have to check each Item.Email1Address against every other,
get a collection of "hits," and then call a routine for
merging them? I'd probably have to use the entryID
property to track each, because deleting an item will
change its numbering in the collection, right?

The problem with this method is that it seems really
time-consuming (even for a computer!) to check every
contact against every other. I've toyed with the idea
of exporting an entire Contacts folder to Excel, sorting
it on the Email1Address field (for example), and using
an Excel routine to consolidate contact info. Doing it
this way would speed things up because all the duplicates
would be adjacent to each other.

But there must be a more elegant way to do this.

Regards,
mvsmith
Sue Mosher [MVP-Outlook] - 29 Jul 2005 02:17 GMT
That's definitely the hard way. Instead check to see if there are any matches at all using the MAPIFolder.Items.Find method, assuming objContacts is your Contacts folder and strAddress is a variable with the email address:

   Set cItems = objContacts.Items
   strFind = "[Email1Address] = " & _
       Chr(34) & strAddress & Chr(34)
   Set dupItem = cItems.Find(strFind)
   If Not dupItem is Nothing Then
       ' do whatever you need to do to dupItem
   End If

Repeat as needed. Or use Restrict instead of Find if you suspect there may be more than on duplicate.

Signature

Sue Mosher, Outlook MVP
Author of
    Microsoft Outlook Programming - Jumpstart for
    Administrators, Power Users, and Developers
    http://www.outlookcode.com/jumpstart.aspx

> I've been looking for many hours for some simple open-source
> VBA code that doesn't delete duplicate contacts, but
[quoted text clipped - 22 lines]
> Regards,
> mvsmith
Chris Kinata - 29 Jul 2005 23:56 GMT
Thanks, Sue, the Restrict method is what I was looking for.

Gotta get your book...

Regards,
Chris

||||| www.kinata.net web design and hosting

That's definitely the hard way. Instead check to see if there are any matches at all using
the MAPIFolder.Items.Find method, assuming objContacts is your Contacts folder and
strAddress is a variable with the email address:

   Set cItems = objContacts.Items
   strFind = "[Email1Address] = " & _
       Chr(34) & strAddress & Chr(34)
   Set dupItem = cItems.Find(strFind)
   If Not dupItem is Nothing Then
       ' do whatever you need to do to dupItem
   End If

Repeat as needed. Or use Restrict instead of Find if you suspect there may be more than on
duplicate.

Signature

Sue Mosher, Outlook MVP
Author of
    Microsoft Outlook Programming - Jumpstart for
    Administrators, Power Users, and Developers
    http://www.outlookcode.com/jumpstart.aspx

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.