Looking for code on resolving duplicates


C

Chris Kinata

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
 
Ad

Advertisements

S

Sue Mosher [MVP-Outlook]

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.

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

Advertisements

C

Chris Kinata

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.

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top