Solved

Outlook - Deleting a Category from Contacts

Posted on 2011-09-02
4
429 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 93

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 93

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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

What does UTC stand for?  “Coordinated Universal Time” – Think of this as the true time on Planet Earth that never changes with the exception of minor leap seconds here and there to account for the changes in the planet's rotation.   What does th…
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

626 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