A user decided the BCM was overkill for his needs and wanted to move his 5000 Business Contacts into Outlook Contacts before upgrading to Office 365. The only issue was keeping the contact associated with the Account name it was assigned to in BCM. The Company name field was suitable, but he needed to update 5000 contacts, which would take "forever".
This macro adds the Account's display name to the company field (only if the company name field is empty). It's not the fastest macro in the world (it takes several minutes to check 5000 contacts), but it is faster than other methods. After it's finished, Select All (Ctrl+A) and drag the contacts from Business Contacts to Outlook's Contacts folder.
Public Sub ChangeFileAs() Dim olApp As Outlook.Application Dim objNS As Outlook.NameSpace Dim olFolders As Outlook.Folders Dim bcmRootFolder As Outlook.Folder Dim bcmContactsFldr As Outlook.Folder Dim objItems As Outlook.Items Dim obj As Object Dim objContact As Outlook.ContactItem Set olApp = CreateObject("Outlook.Application") Set objNS = olApp.GetNamespace("MAPI") Set olFolders = objNS.Session.Folders Set bcmRootFolder = olFolders("Business Contact Manager") Set bcmContactsFldr = bcmRootFolder.Folders("Business Contacts") Set objItems = bcmContactsFldr.Items For Each obj In objItems Set objContact = obj With objContact If .CompanyName = "" Then .CompanyName = .UserProperties("ParentDisplayName") .Save End If End With Err.Clear Next Set bcmRootFolder = Nothing Set olFolders = Nothing Set objNS = Nothing Set olApp = Nothing End Sub
How to use macros
First: You will need macro security set to low during testing.
To check your macro security in Outlook 2010 or 2013, go to File, Options, Trust Center and open Trust Center Settings, and change the Macro Settings. In Outlook 2007 and older, it’s at Tools, Macro Security.
After you test the macro and see that it works, you can either leave macro security set to low or sign the macro.
Open the VBA Editor by pressing Alt+F11 on your keyboard.
To put the code in a module:
- Right click on Project1 and choose Insert > Module
- Copy and paste the macro into the new module.
More information as well as screenshots are at How to use the VBA Editor