The problem with entering contact information on your Phone and Outlook and anything else that may be syncing with your contacts is that a lot of the time you end up with information they may not be entered in a uniform way. The File As attribute is often one of these problems where some contacts are filed as "First Last" while others are filed as "Last, First". The steps below will hopefully help you setup Outlook so it is uniform across all your contacts.
Step 1. Set Outlook to default to your preference.
Step 2. Setup Security on Outlook to Allow for Unsigned Macros
Step 3. Installing the Code
Public Sub ChangeFileAs() 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 strFirstName As String Dim strLastName As String Dim strFileAs As String 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 'Test for contact and not distribution list If obj.Class = olContact Then Set objContact = obj With objContact strFirstName = .FirstName strLastName = .LastName strFileAs = strFirstName & " " & strLastName .FileAs = strFileAs .Save End With End If Err.Clear Next Set objOL = Nothing Set objNS = Nothing Set obj = Nothing Set objContact = Nothing Set objItems = Nothing Set objContactsFolder = NothingEnd Sub
Step 4. Saving the Code and Running the Macro
Step 5. Change Security on Outlook back to not allow for Unsigned Macros
Notes:
Credits:
The Sample code used here was obtained from the FileAs VBA Code sample from Slovaktech.
Whenever I create a new contact on my pda, it default to "last name, first name", would it be possible to change the default setting to 'first name last name"?
This is FANTASTIC! I have been searching for something like this for years and have found no good solutions. Frankly, this shouldn't be necessary because MS should have something for it...
Thank you so much!
Thank you! This worked perfectly in Outlook 2007! Very silly that Microsloth hasn't built this into Outlook.