• Outlook User
  • Exchange Admin
  • Office 365
  • Outlook Developer
  • Outlook.com
  • Outlook Mac
  • Outlook & iCloud
    • Common Problems
    • Outlook BCM
    • Utilities & Addins

Bulk Change File As Format for Contacts

Slipstick Systems

› Outlook › People › Bulk Change File As Format for Contacts

Last reviewed on November 20, 2019     121 Comments

Applies to: Outlook 365 (Win), Outlook 2019 (Win), Outlook 2016 (Win), Outlook 2013, Outlook 2010, Outlook 2007

I call this my "super-duper bulk contacts changer" code because it's so easy to modify to use with other contact fields. Customize the code yourself or use the "Bulk change Contacts" VBA samples at Move Phone Numbers to a Different Phone Field and Change Email Display Name Format. Want to change the FileAs field in all contacts to match the setting in Options? I have a macro for that too: Change FileAs format to match Outlook's default setting. If the first and last names are in the wrong fields, use this macro to swap them: Swap First and Last Name Fields

A Powershell version is also available: Use PowerShell to Bulk Change Contacts

To change the default File As format used for new contacts, go to Tools, Options, Contacts options in older versions or File, Options, Contact (or People) options in Outlook 2010 and newer.

Change the default format in Contact Options

Outlook's Contact's offer a number of File As formats and this format can be used for the contact's name display in the Address Book. However changing the File As format on a large number of contact's is time-consuming when you need to change the contacts one by one. You can do it using VBA or a utility (listed below).

Change the FileAs format in Outlook's Contacts

The file as format options are shown in the screenshot. The VBA code sample supports all 5 formats.

Along with changing the File As order, you can change the order Outlook assumes you use when you enter the name. This setting determines how the names populate the dialog when you press the Full name button. If the name order is wrong in FileAs ("Mary, Smith" when using last, first format), check this setting. If you choose Last First format you don't need to use a comma to separate the names when you enter them and First Last1 Last2 correctly puts the name in the middle position into the last name field, not the middle name field. Outlook will detect names separated by commas as Last, First format, regardless of the Fullname format setting.

VBA Sample

The following code sample supports all 5 File As formats available in Outlook. Press Alt+F11 to open the VBA editor then copy and paste into ThisOutlookSession. Uncomment the strFileAs line that uses the format you desire before running it. (Uncomment the line by removing the apostrophe from in front of the strFileAs = [name_format] command you wish to use.)

See page 2 (or the text file below) for code sample 2 to change the FileAs format on selected contacts.

To test for a value (such as Company name) and use a different File As format if the value is empty, you need to use an If... Then statement.

            With objContact
                If .CompanyName = "" Then
            ' Firstname Lastname format
                   strFileAs = .FullName
               Else
            ' Company name only
                   strFileAs = .CompanyName
               End If
               .FileAs = strFileAs
               .Save
            End With

See Bulk change FileAs format to match Outlook's default setting for a version of this macro that reads the default setting in the registry and applies it to existing contacts.

Run Macro button or press F5To use, select the Contacts folder in Outlook then return to the VBA Editor and press the Run button or F5 to run the macro. You can run the macro later by pressing Alt+F8 (after selecting the Contacts folder) then choosing the macro and pressing Run.

To help eliminate errors, we have text files containing the VBA code samples available. To use, open the text file and Select all (Ctrl+A), copy then paste into the VBA editor. To save to your computer, right-click and choose 'Save Target as'.
Original code - change contacts in default folder | Change selected contacts in any folder

Public Sub ChangeFileAs()
'Fromhttp://slipstick.me/5z
    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
            ' Uncomment the  strFileAs line for the desired format
            ' Comment out strFileAs = .FullName (unless that is the desired format)

                'Lastname, Firstname (Company) format               
                ' strFileAs = .FullNameAndCompany 
                
                'Firstname Lastname format
                 strFileAs = .FullName
               
                'Lastname, Firstname format
                ' strFileAs = .LastNameAndFirstName
               
                'Company name only
                ' strFileAs = .CompanyName
               
                'Companyname (Lastname, Firstname)
                ' strFileAs = .CompanyAndFullName
                
               .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 = Nothing
End Sub

Test for Names and Company

If you have a mix of contacts for people, with a value in the Fullname field, and companies, where the Fullname field is blank, you can replace the With objContact... End with code block with the snippet below.

This code checks for a value in the fullname field and if it's blank, it looks for a company name. If a value is in the company name field, it's used in the FileAs field.

            With objContact
             ' Test for blank name field
             If objContact.FullName = "" Then
                If objContact.CompanyName <> "" Then
                   .FileAs = .CompanyName
                End If
             Else
                .FileAs = .FullName
             End If      
             .Save
            End With

Change Mailing address

If you need to switch the mailing address to the business address field (or from business to home address) you can check for a value in the business address field, and if not blank, copy it to the .MailingAddress field.

Use .HomeAddress if you want to make the home address the mailing address.

As with the code above, replace the With objContact... End with code block in the macro with the snippet below.

            With objContact
               If .BusinessAddress <> "" Then
                 .MailingAddress = .BusinessAddress
                 .Save
               End If
            End With

Customize the code

I call this code sample my "super-duper bulk contact changer macro" because it's so easy to change it to work on other Contact fields. Simply replace section in the original macro that changes the FileAs field with other fields.

For example, changing it to .Body = "" will erase text from the body, solving a problem Nox had syncing contacts to a smart phone. If the phone can handle some text, you could keep some of the text, replacing 1024 with the number of characters you want to keep.

      ' keep some text 
               .Body = Left(.Body, 1024)

 If obj.Class = olContact Then
        Set objContact = obj

            With objContact

      ' erase the entire body
               .Body = ""

               .Save
            End With
End If

Common Errors

Colors when the code is correct
After pasting the code into the VB editor, the colors should be similar to the colors in this screenshot (and as seen in the code sample above).

Any text shown in Red has an error in it.

Blue, Black, and Green are "good", with the Blue color indicating VBA commands (If, Then, End etc), Black is your variables, and Green is used for comments. The second line in one of the 5 sets of Green lines needs to have Black text. You do this by removing the apostrophe (') from in front of the line. If more than one of those 5 lines is black, add an apostrophe to front of the format line you don't want to use. (In my screenshot, the second set is the format I want to use.)

Change only the 'subject' field used by the Address book

Note: this was written for an older versions of Outlook and is not needed with new versions.

Use the Outlook File As Order custom form to change just the display in the Address book, from Last name first, to First name first or use the File As entry.

Notes:

  • This method will not change the actual sort order in the Contacts folder or format used on the File As field.
  • Will return an error if there are distribution lists in the Contacts folder.
  • This has the same options as you'll find in Tools, E-mail Accounts, View or change existing Address books, Outlook Address book properties, but also adds Last name first option and full File As format, including the Company name.
  • Works on any contact folder - select the folder before clicking Run in the VB Editor or pressing F5. Leave the editor open and select another folder to use it on additional folders.

The original code works on the default Contacts folder and many users asked for a version that worked on the selected folder. We edited the code to change the selected contacts in any folder. Note that you do need to select the contacts, not just the folder.

Code Sample 2: Change FileAs on Selected Contacts

This code sample is an edited version of the previous code and works on the selected folder. I tested it in Outlook 2010 but it should work in all versions that the original code works with. This is the same code that is in the text file on page 1.

To use, you need to select the contacts. Use Select All (Ctrl+A) to apply it to all contacts in a folder or use Ctrl+click to select some contacts.

Public Sub ChangeFileAsSelectedContacts()
    Dim Session As Outlook.NameSpace
    Dim currentExplorer As Explorer
    Dim Selection As Selection
    Dim currentItem As Object
    Dim folder As Outlook.folder
    
    Dim obj As Object
    Dim strFirstName As String
    Dim strLastName As String
    Dim strFileAs As String

    Set currentExplorer = Application.ActiveExplorer
    Set Selection = currentExplorer.Selection

    On Error Resume Next

    For Each obj In Selection
    Set folder = currentItem.Parent
        'Test for contact and not distribution list
        If obj.Class = olContact Then
            Set objContact = obj

            With objContact
            ' Uncomment the  strFileAs line for the desired format

                'Lastname, Firstname (Company) format
                ' strFileAs = .FullNameAndCompany
                
                'Firstname Lastname format
                 strFileAs = .FullName
               
                'Lastname, Firstname format
               '  strFileAs = .LastNameAndFirstName
               
                'Company name only
                ' strFileAs = .CompanyName
               
                'Companyname (Lastname, Firstname)
                ' strFileAs = .CompanyAndFullName
                
               .FileAs = strFileAs

                .Save
            End With
        End If

        Err.Clear
    Next

    Set Session = Nothing
    Set currentExplorer = Nothing
    Set obj = Nothing
    Set Selection = Nothing
    Set currentItem = Nothing
    Set folder = Nothing
End Sub

More Information

More Bulk Change Contact articles at Slipstick.com:

  • Bulk Change Contact's FileAs Format to Match Outlook's Default Setting
  • Bulk Change File As Format for Contacts
  • Bulk Move Phone Numbers to a Different Phone Field
  • Macro to Swap First and Last Name Fields
  • Show the Home Address on a Contact Form by Default
  • Update Contact Area Codes
  • Update Contacts with a New Company Name and Email Address

Bulk Change File As Format for Contacts was last modified: November 20th, 2019 by Diane Poremsky
  • Twitter
  • Facebook
  • LinkedIn
  • Reddit
  • Print

Related Posts:

  • Bulk Change Email Display Name Format
  • Bulk Move Phone Numbers to a Different Phone Field
  • Bulk Change Contact's FileAs Format to Match Outlook's Default Setting
  • Use PowerShell to Bulk Change Contacts

About Diane Poremsky

A Microsoft Outlook Most Valuable Professional (MVP) since 1999, Diane is the author of several books, including Outlook 2013 Absolute Beginners Book. She also created video training CDs and online training classes for Microsoft Outlook. You can find her helping people online in Outlook Forums as well as in the Microsoft Answers and TechNet forums.

Subscribe
Notify of
121 Comments
newest
oldest most voted
Inline Feedbacks
View all comments

Phil (@guest_219219)
April 20, 2022 9:05 am
#219219

Is there a way to use this to change which phone numbers appear? The defaults are Business, Home, Business Fax and Mobile, and if you change which one displays in the drop-down, Outlook remembers your choice for that contact, but not for all contacts.

0
0
Reply
Diane Poremsky(@diane-poremsky)
Author
Reply to  Phil
April 20, 2022 10:39 am
#219220

You can use a custom form to change it for all - https://www.slipstick.com/outlook/people/show-the-home-address-on-contact-form/ - and then can change the existing contacts to use the custom form but cannot change the order on the numbers using vba (other than changing which field the number is in).

0
0
Reply
Mike Shick (@guest_217206)
November 20, 2020 2:44 pm
#217206

Is there an option to file as first last (company)?

0
0
Reply
Diane Poremsky(@diane-poremsky)
Author
Reply to  Mike Shick
November 20, 2020 4:09 pm
#217208

First last, no, only last, first

'Lastname, Firstname (Company) format  
' strFileAs = .FullNameAndCompany 

0
0
Reply
NT4Boy (@guest_215059)
April 18, 2020 5:09 am
#215059

I use Office 2016 therefore Outlook 2016 with outlook.com as my exchange server.
Most of the mail attachments I send get converted to winmail.dat, whereas in Office 2007 they didn't. Obvious workarounds using cloud storage, but its the MOST frustating thing.
Tried to fix this for months. Looked at hundreds of Googled suggestions for setting format to HTML, and also doing the Disable TNEF registry hack to no avail.
What does work in some instances is to delete the email contact from pst/ contacts, and recreate new from scratch.
With a huge contacts list of several hundred entries, I did wonder if this script could be used to perhaps rewrite the mail send format HTML entry for each contact.

Appreciate your advice.

0
0
Reply
Lorraine (@guest_215007)
April 6, 2020 9:33 am
#215007

Ok, thank you for posting this. But, I am not making head or tails of it - I do not know what to do.. Maybe step by step for each option should be listed. "If you want to safe as Name Surname, then use this code: " Right now I am looking at the codes and do not understand what I am to do. The only thing I get is that this is the answer to my problem.

0
0
Reply
Mark (@guest_214323)
November 19, 2019 4:29 pm
#214323

The page says ...

"To change the default File As format used for new contacts, go to Tools, Options, Contacts options in older versions or File, Options, Contact options in Outlook 2010 and newer."

Minor point:
For Outlook 2016, the menu path is File, Options, People.

0
0
Reply
Josh (@guest_196030)
January 20, 2016 8:44 am
#196030

Running Outlook 2010 - couldn't get the first VBA code to work but the Sample 2 Code on selected contacts worked. Although, I did move the ".FileAs = strFileAs" (Ln 42, Col 16) over a space to line up the indent with the line above before I ran the code, possible code error? Don't know much VBA but hope this helps someone

0
0
Reply
G (@guest_194979)
November 27, 2015 10:00 am
#194979

Help!

Doesn't work on "Suggested Contacts", but works great on "Contacts". Any tips on modifying the code?

running Outlook 2010

1
0
Reply
Diane Poremsky(@diane-poremsky)
Author
Reply to  G
November 27, 2015 11:25 am
#194980

This tells the macro which folder to use -
Set objContactsFolder = objNS.GetDefaultFolder(olFolderContacts)
for suggested contacts (or other folders at the same level as contacts), use
Set objContactsFolder = objNS.GetDefaultFolder(olFolderContacts).parent.folders("Suggested contacts")

1
0
Reply
Richard Smith (@guest_189593)
March 3, 2015 5:56 pm
#189593

When I imported the outlook data file, some of my contacts' home addresses ended up showing as business addresses. Any way to convert those addresses from the business address column to the home address column?

1
0
Reply
Diane Poremsky(@diane-poremsky)
Author
Reply to  Richard Smith
April 1, 2015 1:13 am
#190138

You can use the macro - just change which fields you are swapping.
Samples here https://www.slipstick.com/outlook/contacts/bulk-move-phone-numbers-to-a-different-phone-field/ and here
https://www.slipstick.com/developer/code-samples/working-items-folder-selected-items/

1
0
Reply

Visit Slipstick Forums.
What's New at Slipstick.com

Latest EMO: Vol. 28 Issue 22

Support Services

Do you need help setting up Outlook, moving your email to a new computer, migrating or configuring Office 365, or just need some one-on-one assistance?

Subscribe to Exchange Messaging Outlook






Our Sponsors

CompanionLink
ReliefJet
  • Popular
  • Latest
  • WeekMonthAll
  • How to Remove the Primary Account from Outlook
  • Adjusting Outlook's Zoom Setting in Email
  • Outlook: Web Bugs & Blocked HTML Images
  • Save Sent Items in Shared Mailbox Sent Items folder
  • Move an Outlook Personal Folders .pst File
  • Create rules that apply to an entire domain
  • Use PowerShell to get a list of Distribution Group members
  • View Shared Calendar Category Colors
  • How to Create a Pick-a-Meeting Request
  • Outlook Auto Account Setup: Encrypted Connection not available
  • Send Individual Messages when Sending Bulk Email
  • Centrally managed signatures in Office 365?
  • Create a rule to delete spam with no sender address
  • Open Outlook Folders using PowerShell or VBScript
  • Cannot add Recipients in To, CC, BCC fields on MacOS
  • Change Appointment Reminder Sounds
  • Messages appear duplicated in message list
  • Reset the New Outlook Profile
  • Delete Old Calendar Events using VBA
  • Use PowerShell or VBA to get Outlook folder creation date
Ajax spinner

Newest Code Samples

Delete Old Calendar Events using VBA

Use PowerShell or VBA to get Outlook folder creation date

Rename Outlook Attachments

Format Images in Outlook Email

Set Outlook Online or Offline using VBScript or PowerShell

List snoozed reminders and snooze-times

Search your Contacts using PowerShell

Filter mail when you are not the only recipient

Add Contact Information to a Task

Process Mail that was Auto Forwarded by a Rule

Recent Bugs List

Microsoft keeps a running list of issues affecting recently released updates at Fixes or workarounds for recent issues in Outlook for Windows.

Outlook for Mac Recent issues: Fixes or workarounds for recent issues in Outlook for Mac

Office Update History

Update history for supported Office versions is at Update history for Office

Outlook Suggestions and Feedback

Outlook Feedback covers Outlook as an email client, including Outlook Android, iOS, Mac, and Windows clients, as well as the browser extension (PWA) and Outlook on the web.

Use Outlook.com Feedback for suggestions or feedback about Outlook.com accounts.

Other Microsoft 365 applications and services




Windows 10 Issues

  • iCloud, Outlook 2016, and Windows 10
  • Outlook Links Won’t Open In Windows 10
  • Outlook can’t send mail in Windows 10: error Ox800CCC13
  • Missing Outlook data files after upgrading Windows?

Outlook Top Issues

  • The Windows Store Outlook App
  • The Signature or Stationery and Fonts button doesn’t work
  • Outlook’s New Account Setup Wizard
  • Outlook 2016: No BCM
  • Exchange Account Set-up Missing in Outlook 2016

VBA Basics

How to use the VBA Editor

Work with open item or selected item

Working with All Items in a Folder or Selected Items

VBA and non-default Outlook Folders

Backup and save your Outlook VBA macros

Get text using Left, Right, Mid, Len, InStr

Using Arrays in Outlook macros

Use RegEx to extract message text

Paste clipboard contents

Windows Folder Picker

Custom Forms

Designing Microsoft Outlook Forms

Set a custom form as default

Developer Resources

Developer Resources

Developer Tools

VBOffice.net samples

SlovakTech.com

Outlook MVP David Lee

Repair PST

Convert an OST to PST

Repair damaged PST file

Repair large PST File

Remove password from PST

Merge Two Data Files

Sync & Share Outlook Data

  • Share Calendar & Contacts
  • Synchronize two computers
  • Sync Calendar and Contacts Using Outlook.com
  • Sync Outlook & Android Devices
  • Sync Google Calendar with Outlook
  • Access Folders in Other Users Mailboxes

Contact Tools

Data Entry and Updating

Duplicate Checkers

Phone Number Updates

Contact Management Tools

Diane Poremsky [Outlook MVP]

Make a donation

Calendar Tools

Schedule Management

Calendar Printing Tools

Calendar Reminder Tools

Calendar Dates & Data

Time and Billing Tools

Meeting Productivity Tools

Duplicate Remover Tools

Mail Tools

Sending and Retrieval Tools

Mass Mail Tools

Compose Tools

Duplicate Remover Tools

Mail Tools for Outlook

Online Services

Productivity

Productivity Tools

Automatic Message Processing Tools

Special Function Automatic Processing Tools

Housekeeping and Message Management

Task Tools

Project and Business Management Tools

Choosing the Folder to Save a Sent Message In

Run Rules on messages after reading

Help & Suggestions

Submit Outlook Feature Requests

Slipstick Support Services

Home | Outlook User | Exchange Administrator | Office 365 | Outlook.com | Outlook Developer
Outlook for Mac | Common Problems | Utilities & Addins | Tutorials
Outlook & iCloud Issues | Outlook Apps
EMO Archives | About Slipstick | Advertise | Slipstick Forums
Submit New or Updated Outlook and Exchange Server Utilities

Send comments using our Feedback page
Copyright © 2023 Slipstick Systems. All rights reserved.
Slipstick Systems is not affiliated with Microsoft Corporation.

wpDiscuz

Sign up for Exchange Messaging Outlook

Our weekly Outlook & Exchange newsletter (bi-weekly during the summer)






Please note: If you subscribed to Exchange Messaging Outlook before August 2019, please re-subscribe.

Never see this message again.

You are going to send email to

Move Comment