Solved

Outlook - Deleting a Category from Contacts

Posted on 2011-09-02
4
424 Views
Last Modified: 2012-08-13
Looking for someone willing to right a script that can detect all contacts with a certain category, remove and replce the catagory in all the contact records.
0
Comment
Question by:afreestyle
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 92

Accepted Solution

by:
Patrick Matthews earned 500 total points
ID: 36475798
The following works in Outlook 2007.

It's a bit tricky: Outlook stores category assignments as a comma delimited list, so you have to be very careful about doing the replacements.

Sub ReplaceCategory()
    
    Dim fld As Folder
    Dim it As Object
    Dim Counter As Long
    
    Const OldCat = "Foo"
    Const NewCat = "Hee"
    
    Set fld = Application.GetNamespace("MAPI").GetDefaultFolder(olFolderContacts)
    For Each it In fld.Items
        If it.Class = olContact Then
            If InStr(1, ", " & it.Categories & ", ", ", " & OldCat & ", ") > 0 Then
                If it.Categories Like OldCat & ", *" Then
                    it.Categories = Replace(it.Categories, OldCat, NewCat, 1, 1)
                ElseIf it.Categories Like "*, " & OldCat Then
                    it.Categories = Left(it.Categories, Len(it.Categories) - Len(OldCat)) & NewCat
                Else
                    it.Categories = Replace(it.Categories, ", " & OldCat & ", ", ", " & NewCat & ", ")
                End If
                it.Save
                Counter = Counter + 1
            End If
        End If
    Next
    
    MsgBox "Done; " & Counter & " contacts updated"
    
End Sub

Open in new window

0
 

Author Comment

by:afreestyle
ID: 36475811
Thank you for the quick responce. Could you possibly add a quick blub on how to run this?
0
 
LVL 92

Assisted Solution

by:Patrick Matthews
Patrick Matthews earned 500 total points
ID: 36475870
From Outlook, hit Alt+F11 to get t the VB Editor.

Insert a new module, and paste my code in there.  Modify the contants for the old category and the new category.  To run it, hit F5 in the VB Editor, or Alt+F8 from Outlook.
0
 

Author Comment

by:afreestyle
ID: 36475946
Am I missing a step?

Everything seems to function, but when I go look at the contact it is still categorised as Foo.

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Keyword email search on Exchange 2010 4 49
Outlook PST (cloud) backup 3 86
Exchange 2010 CAS array Load Balancing. 7 59
Outlook 2010 hyperlink issue 3 41
Are you unable to connect or configure Hotmail email account in Microsoft Outlook 2010, 2007? Or Outlook.com emails are not downloading to Outlook? Lets’ see the problem and resolve Outlook Connector error syncing folder hierarchy (0x8004102A).
How to resolve IMCEAEX NDRs in Exchange or Exchange Online related to invalid X500 addresses.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question