Help with Macro to copy Outlook Contact fields RRS feed

  • Question

  • I need to copy each Outlook Contact’s created date to the “Profession” field (if Profession field is blank, because I will re-run this periodically). The reason is that some sync services (Contacts+) very frustratingly overwrite the contacts’ created date, and a I want a permanent record of when each contact was created by me.

    Sue Mosher shared this awesome Macro[1]. Can you help me insert the IF logic?

    And I presume I only need to replace field names as needed from the Microsoft documentation[2]? So:

    objItem.Profession = objItem.CreationTime

    Finally, can you help me tweak this to delete a field if it exists (for example, I never want the Fax fields populated)? Should I could use this?

    objItem.BusinessFaxNumber = ""
    objItem.HomeFaxNumber = ""
    objItem.OtherFaxNumber = ""

    Sub CopyCats()
        Dim objNS As Outlook.NameSpace
        Dim objItems As Items
        Dim objItem As Object
        Set objNS = Application.session
        Set objItems = objNS.GetDefaultFolder(olFolderContacts).Items
        For Each objItem In objItems
            ' make sure you have a Contact item
            If objItem.Class = olContact Then
                ' copy data
                objItem.User1 = objItem.Categories
            End If
       Set objItems = Nothing
       Set objItem = Nothing
        Set objNS = Nothing
    End Sub

    [1] https://social.technet.microsoft.com/Forums/lync/en-US/3692b630-4670-4ae9-884c-bf61454f0148/copy-contact-data-from-one-field-to-another?forum=outlook

    [2] https://docs.microsoft.com/en-us/office/vba/outlook/Concepts/Forms/outlook-fields-and-equivalent-properties

    • Edited by rotorba Thursday, December 17, 2020 3:05 PM remove dupe
    Thursday, December 17, 2020 3:05 PM