• Outlook User
  • New Outlook app
  • Outlook.com
  • Outlook Mac
  • Outlook & iCloud
  • Developer
  • Microsoft 365 Admin
    • Common Problems
    • Microsoft 365
    • 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     131 Comments

Applies to: Outlook (classic), Outlook 2007, Outlook 2010, Outlook 365 (Win)

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.
 

Tools

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

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
131 Comments
newest
oldest most voted
Inline Feedbacks
View all comments

Mraaaa
December 3, 2024 3:43 pm

This worked, thank you!! Is there a way to customize the format of the FileAs field? I want it to be "FirstName Lastname, (Company)"

0
0
Reply
Diane Poremsky
Author
Reply to  Mraaaa
December 5, 2024 9:21 pm

If the default formats don't meet your needs, you can use a custom format in the script.

strFileAs = .LastNameAndFirstName &", (" & .CompanyName & ")"

0
0
Reply
Diane Poremsky
Author
Reply to  Diane Poremsky
December 5, 2024 9:24 pm

oops... you want first last (company) - same deal, just different field names.

strFileAs = .FullName & ", (" & .CompanyName & ")"

could also do it like this -
strFileAs = .Firstname & " " & .lastname &", (" & .CompanyName & ")"

0
0
Reply
Robert A Lucido
September 18, 2024 5:44 pm

Hi... I need to do the opposite, I need to move the File As field into the First Name field can I just change str in the code?

0
0
Reply
Diane Poremsky
Author
Reply to  Robert A Lucido
September 26, 2024 12:48 am

Yes, you would use .firstname = .fileas

0
0
Reply
Amit
September 10, 2024 4:40 am

Is there a way to delete content in the Title field? Some of my contacts are saved as 'Mr', 'Ms', 'Dr', etc., and I wanted to bulk delete all entries in that field to provide consistency.

0
0
Reply
Diane Poremsky
Author
Reply to  Amit
September 10, 2024 9:28 am

Yes, you can use the macro or PowerShell to delete it. The field name is .title

VBA change

With objContact
     
' remove all the lines between the first and last two lines 

' add this
   .title = ""

.Save

End With

PowerShell is here - it's a little easier because you don't need to change macro security settings.
https://www.slipstick.com/developer/powershell-bulk-change-contacts/

foreach ($Contact in $Contacts.Items)
{

' remove all the lines between the first and last lines 

' add this
$contact.title = ""

   
   $Contact.Save()

0
0
Reply
Robert A Lucido
Reply to  Diane Poremsky
September 26, 2024 8:01 am

Thank you... I got so frustrated trying to get it to work, I exported into CSV moved my fields and now hope to bring it back in... if that doesn't work I'll run this powershell

0
0
Reply
Amit
Reply to  Amit
September 24, 2024 2:09 am

So it should look like this?

$olApp = new-object -comobject outlook.application
$namespace = $olApp.GetNamespace("MAPI")

# Default Contacts folder
$Contacts = $namespace.GetDefaultFolder(10)

# Uses current folder
#$Contacts = ($olApp.ActiveExplorer()).CurrentFolder

foreach ($Contact in $Contacts.Items)
{

$contact.title - ""

  $Contact.Save()

   }
}

$olApp.Quit | Out-Null
[GC]::Collect()

0
0
Reply
Diane Poremsky
Author
Reply to  Amit
September 25, 2024 11:16 pm

I see two typos - sorry.

foreach ($Contact in $Contacts.Items)
{

$contact.title = "" this needs to be an equal sign.

$Contact.Save()

}
}
There should only be one closing bracket.

This code will skip contact groups - otherwise, there will a PowerShell error when it looks for the title filed in the groups.

$olApp = new-object -comobject outlook.application
$namespace = $olApp.GetNamespace("MAPI")

# Default Contacts folder
#$Contacts = $namespace.GetDefaultFolder(10)
# Uses current folder
$Contacts = ($olApp.ActiveExplorer()).CurrentFolder

foreach ($Contact in $Contacts.Items)
{

# Don't change distribution lists
    if ($Contact.messageclass -notlike "*distlist*")
    {
              
   $Contact.title  = ""  
   $Contact.Save()

    }
}

$olApp.Quit | Out-Null
[GC]::Collect()

0
0
Reply
Phil
April 20, 2022 9:05 am

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
Author
Reply to  Phil
April 20, 2022 10:39 am

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
November 20, 2020 2:44 pm

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

0
0
Reply
Diane Poremsky
Author
Reply to  Mike Shick
November 20, 2020 4:09 pm

First last, no, only last, first

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

0
0
Reply
NT4Boy
April 18, 2020 5:09 am

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
April 6, 2020 9:33 am

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
November 19, 2019 4:29 pm

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

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

Latest EMO: Vol. 30 Issue 29

Subscribe to Exchange Messaging Outlook






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?

Our Sponsors

CompanionLink
ReliefJet
  • Popular
  • Latest
  • Week Month All
  • Jetpack plugin with Stats module needs to be enabled.
  • Open Outlook Templates using PowerShell
  • Count and List Folders in Classic Outlook
  • Google Workspace and Outlook with POP Mail
  • Import EML Files into New Outlook
  • Opening PST files in New Outlook
  • New Outlook: Show To, CC, BCC in Replies
  • Insert Word Document into Email using VBA
  • Delete Empty Folders using PowerShell
  • Warn Before Deleting a Contact
  • Classic Outlook is NOT Going Away in 2026
Ajax spinner

Recent Bugs List

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

For new Outlook for Windows: Fixes or workarounds for recent issues in new Outlook for Windows .

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

Outlook.com Recent issues: Fixes or workarounds for recent issues on Outlook.com

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.

Outlook (new) Feedback. Use this for feedback and suggestions for Outlook (new).

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

Other Microsoft 365 applications and services




New Outlook Articles

Open Outlook Templates using PowerShell

Count and List Folders in Classic Outlook

Google Workspace and Outlook with POP Mail

Import EML Files into New Outlook

Opening PST files in New Outlook

New Outlook: Show To, CC, BCC in Replies

Insert Word Document into Email using VBA

Delete Empty Folders using PowerShell

Warn Before Deleting a Contact

Classic Outlook is NOT Going Away in 2026

Newest Code Samples

Open Outlook Templates using PowerShell

Count and List Folders in Classic Outlook

Insert Word Document into Email using VBA

Warn Before Deleting a Contact

Use PowerShell to Delete Attachments

Remove RE:, FWD:, and Other Prefixes from Subject Line

Change the Mailing Address Using PowerShell

Categorize @Mentioned Messages

Send an Email When You Open Outlook

Delete Old Calendar Events using VBA

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

Diane Poremsky [Outlook MVP]

Make a donation

Mail Tools

Sending and Retrieval Tools

Mass Mail Tools

Compose Tools

Duplicate Remover Tools

Mail Tools for Outlook

Online Services

Calendar Tools

Schedule Management

Calendar Printing Tools

Calendar Reminder Tools

Calendar Dates & Data

Time and Billing Tools

Meeting Productivity Tools

Duplicate Remover Tools

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

Buy Microsoft 365 Office Software and Services

Visit Slipstick Forums.

What's New at Slipstick.com

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 | Slipstick Forums
Submit New or Updated Outlook and Exchange Server Utilities

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

:wpds_smile::wpds_grin::wpds_wink::wpds_mrgreen::wpds_neutral::wpds_twisted::wpds_arrow::wpds_shock::wpds_unamused::wpds_cool::wpds_evil::wpds_oops::wpds_razz::wpds_roll::wpds_cry::wpds_eek::wpds_lol::wpds_mad::wpds_sad::wpds_exclamation::wpds_question::wpds_idea::wpds_hmm::wpds_beg::wpds_whew::wpds_chuckle::wpds_silly::wpds_envy::wpds_shutmouth:
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