Sdílet prostřednictvím


Bulk outlook contact edit

 

 

A common scenario:

 

I had a request from customer who’s company has just changed names, and they would like to find out if he can edit the ‘Company’ field in his contacts on bulk to reflect the name change.

 

How can this be done, easily?

 

You can do this with a little bit o'code....and here are some steps to follow:

 

Tested under outlook 2010, but should work for ol2007 and ol2003.

 

1) In your Outlook, right mouse click the ribbon toolbar

2) select the check box that says "Developer", press OK, this will add the developer tab to the ribbon

3) Click on this and select the visual basic button, this will load up the vba environment

4) On the left, you'll see the project window with a module in it, click on it

5) on the right hand side, paste this...

 

Public Sub ChangeMyContact()

   Dim objOL As Outlook.Application

    Dim objNS As Outlook.NameSpace

    Dim objContact As Outlook.ContactItem

    Dim objItems As Outlook.Items

    Dim objContactsFolder As Outlook.MAPIFolder

  Dim obj As Object

  Dim strOldCompanyName As String

    Dim strNewCompanyName As String

 

    strOldCompanyName = "www.djspacebar.com" ' TO DO change here

    strNewCompanyNewName = "www.spacebarproductions.com" 'TODO change here

   

    On Error Resume Next

 

    Set objOL = CreateObject("Outlook.Application")

    Set objNS = objOL.GetNamespace("MAPI")

    Set objContactsFolder = objNS.GetDefaultFolder(olFolderContacts)

    Set objItems = objContactsFolder.Items

 

    For Each obj In objItems

  If obj.Class = olContact Then

            Set objContact = obj

            With objContact

            If .CompanyName = strOldCompanyName Then

                .CompanyName = strNewCompanyNewName

                .Save

            End If

  End With

        End If

       Err.Clear

    Next

 

    Set objOL = Nothing

    Set objNS = Nothing

    Set obj = Nothing

    Set objContact = Nothing

    Set objItems = Nothing

    Set objContactsFolder = Nothing

End Sub

 

6) make the changes in the TODO sections (look for the old company and new company), save it (CTRL+S)

7) close the window

8) in the macros button, you'll see "project1.ChangeMyContact", click on that and that should change all your company name fields.

 

Hope it helps someone

Thanks