Cause the Contacts "File as" fields to correspond to "Name"

jmt356
SilverLounger
Posts: 2381
Joined: 28 Mar 2010, 01:49

Cause the Contacts "File as" fields to correspond to "Name"

Post by jmt356 »

Each time I enter a new Contact into Outlook, Outlook automatically adds the Contact name into the "File as" field and changes the order of the words in the name. This has never really bothered me because it has not impacted the alphabetical display of all of my Contacts by name. However, I have noticed that the Contacts on my phone, which I synchronize with Outlook, are all out of alphabetical order, and I suspect it is because they are being displayed according to the "File as" field rather than according to the Name field.

Is there a way to automatically reset all of my "File as" fields to correspond to the Name fields or does this have to be done manually for each contact?

Is there a way to cause all future entries into the "File as" field to correspond to the Name fields without changing the word order?
Regards,

JMT

User avatar
HansV
Administrator
Posts: 78378
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Cause the Contacts "File as" fields to correspond to "Na

Post by HansV »

Best wishes,
Hans

User avatar
HansV
Administrator
Posts: 78378
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Cause the Contacts "File as" fields to correspond to "Na

Post by HansV »

In Outlook 2010 or 2013: select File > Acccount Settings > Account Settings.
Activate the Address Books tab.
Select Outlook Address Book, then click Change...
You can select your preferred order for "Show names by" here.
Click Close, then Close again, then restart Outlook.
Best wishes,
Hans

jmt356
SilverLounger
Posts: 2381
Joined: 28 Mar 2010, 01:49

Re: Cause the Contacts "File as" fields to correspond to "Na

Post by jmt356 »

HansV wrote:In Outlook 2010 or 2013: select File > Acccount Settings > Account Settings.
Activate the Address Books tab.
Select Outlook Address Book, then click Change...
You can select your preferred order for "Show names by" here.
Click Close, then Close again, then restart Outlook.
It was already set to "First Last" under "Show names by" for both Contacts: Personal Folders and Suggested Contacts: Personal Folders. Yet when I type "John Smith," "Smith, John" is saved in the File as field.

I reselected "First Last" for good order and then exited out and restarted Outlook, but "John Smith" continues to be filed as "Smith, John."
Regards,

JMT

User avatar
HansV
Administrator
Posts: 78378
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Cause the Contacts "File as" fields to correspond to "Na

Post by HansV »

You can select the preferred format in the Contact dialog:
S013.png
For bulk changes, you need a macro, as mentioned in my first reply.
You do not have the required permissions to view the files attached to this post.
Best wishes,
Hans

jmt356
SilverLounger
Posts: 2381
Joined: 28 Mar 2010, 01:49

Re: Cause the Contacts "File as" fields to correspond to "Na

Post by jmt356 »

After I make a bulk change, do I still have to individually choose to file by First Name, Last Name for every new contact that I add?
Regards,

JMT

User avatar
HansV
Administrator
Posts: 78378
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Cause the Contacts "File as" fields to correspond to "Na

Post by HansV »

You can set the default File As order for new contacts in File > Options > Contacts, section 'Names and filing':
S014.png
You do not have the required permissions to view the files attached to this post.
Best wishes,
Hans

jmt356
SilverLounger
Posts: 2381
Joined: 28 Mar 2010, 01:49

Re: Cause the Contacts "File as" fields to correspond to "Na

Post by jmt356 »

Thank you Hans. That worked for changing my default File as format.

I tried to follow the instructions at http://www.slipstick.com/outlook/contac ... as-format/" onclick="window.open(this.href);return false;, but find them very confusing. I got as far as pressing Alt+F11 to open the VBA (Microsoft Visual Basic for Applications) editor and then got stuck.
- The tutorial states to then “Copy and paste into ThisOutlookSession.” Copy and paste what into ThisOutlookSession? And where is ThisOutlookSession?
- I am then to “Uncomment the strFileAs line” that uses the format you desire before running it. Where is the “Uncomment the strFileAs line”?

I would be grateful if anyone can explain these instructions in a more basic, easy-to-understand manner.
Regards,

JMT

User avatar
Rudi
gamma jay
Posts: 25455
Joined: 17 Mar 2010, 17:33
Location: Cape Town

Re: Cause the Contacts "File as" fields to correspond to "Na

Post by Rudi »

Hi JMT,

Try these steps: (see the image below for reference)

Copy the macro code below...(the code is already uncommented, so no need for that step.)
Then, open Outlook.

Follow these steps as illustrated by the numbers on the image below...
1. With Outlook open, press ALT+F11 (this will activate the VB Editor Window where the macro will go)
2. Expand the VBA Project by clicking the "+" button to reveal the ThisOutlookSession module. Now double click on the module called ThisOutlookSession
3. This will activate a module in the big window on the right(if it was not activated already). Paste the macro into this module (below any other macros if there are already macros on the page)
4. Click the Save button and close the VBA editor window (to get back to the Outlook interface)

In Outlook ensure you have clicked on the Contacts button to view your contacts
Now press ALT+F8 (to open the Run Macro dialog)
Select the macro called: ChangeFileAs and click on Run

Code: Select all

Public Sub ChangeFileAs()
'From http://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
S11.jpg
You do not have the required permissions to view the files attached to this post.
Regards,
Rudi

If your absence does not affect them, your presence didn't matter.

jmt356
SilverLounger
Posts: 2381
Joined: 28 Mar 2010, 01:49

Re: Cause the Contacts "File as" fields to correspond to "Na

Post by jmt356 »

After I clicked "Run," I got the error message "The macros in this project are disabled. Please refer to the online help or documentation of the host application to determine how to enable macros."
Regards,

JMT

User avatar
Rudi
gamma jay
Posts: 25455
Joined: 17 Mar 2010, 17:33
Location: Cape Town

Re: Cause the Contacts "File as" fields to correspond to "Na

Post by Rudi »

Seems like your macro security in Outlook is on Notify.

Either you need to enable macros when you open Outlook (image 1)
Or you need to change your trust center settings to allow all macros. (Can be risky depending on untrusted sources) (image 2)
to activate the Developer ribbon in Outlook and access the Macro Security button, see here.
1.jpg
2.jpg
You do not have the required permissions to view the files attached to this post.
Last edited by Rudi on 08 Dec 2014, 12:12, edited 1 time in total.
Regards,
Rudi

If your absence does not affect them, your presence didn't matter.

User avatar
HansV
Administrator
Posts: 78378
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Cause the Contacts "File as" fields to correspond to "Na

Post by HansV »

The easiest solution is:
- Select File > Options.
- Select Trust Center.
- Click Trust Center Settings...
- Select Macro Settings.
- Select "Enable all macros (not recommended; ...)".
- Click OK.
Best wishes,
Hans

jmt356
SilverLounger
Posts: 2381
Joined: 28 Mar 2010, 01:49

Re: Cause the Contacts "File as" fields to correspond to "Na

Post by jmt356 »

HansV wrote:The easiest solution is:
- Select File > Options.
- Select Trust Center.
- Click Trust Center Settings...
- Select Macro Settings.
- Select "Enable all macros (not recommended; ...)".
- Click OK.
I continue to get the same error.

Before programming the macro, I copied the pst to my desktop (as a backup) and then removed it. Now, when I launch Outlook, I get an error message stating that the pst on my desktop cannot be found. I click okay and a window launches asking me to navigate to it, which I cancel. Outlook then launches with the pst saved in my appdata folder. Could the inability to run the macro be related to this?
Regards,

JMT

User avatar
HansV
Administrator
Posts: 78378
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Cause the Contacts "File as" fields to correspond to "Na

Post by HansV »

I don't think that's causing the problem, but I'd try to solve that anyway - you can specify the data file(s) that Outlook should use in File > Info > Acount Settings > Account Settings...
In the Account Settings dialog, activate the Data Files tab. You can add and remove data files here.
Best wishes,
Hans

jmt356
SilverLounger
Posts: 2381
Joined: 28 Mar 2010, 01:49

Re: Cause the Contacts "File as" fields to correspond to "Na

Post by jmt356 »

Thank you. I am not sure what I did (perhaps I restarted Outlook), but the macro provided above is now working.

However, I have noticed another issue. For some contacts, I have added names comprised of several words. Outlook sometimes selects words other than the first one and assigns that as the first name, thus causing the contacts on my phone to appear out of order. Is there a macro that causes Outlook to assign to the first name field of each contact the first word that I have entered for each of the respective names?
Regards,

JMT

User avatar
HansV
Administrator
Posts: 78378
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Cause the Contacts "File as" fields to correspond to "Na

Post by HansV »

Try this macro. I cannot test it myself since I don't want to modify my own contacts.

Code: Select all

Sub FixFirstNames()
    Dim fld As Folder
    Dim itm As Variant
    Set fld = Session.GetDefaultFolder(olFolderContacts)
    For Each itm In fld.Items
        If itm.Class = olContact Then
            itm.FirstName = Split(itm.FullName)(0)
        End If
    Next itm
End Sub
Best wishes,
Hans

jmt356
SilverLounger
Posts: 2381
Joined: 28 Mar 2010, 01:49

Re: Cause the Contacts "File as" fields to correspond to "Na

Post by jmt356 »

I will test the macro, but first, I’d like to address an anomaly I am facing with searching in Outlook. As mentioned above, I copied the pst to my desktop (as a backup) and then removed it, which cuased an error message stating that the pst on my desktop cannot be found whenever I launched Outlook.

I solved that issue by going to File | Open | Open Outlook Data File, navigating to my PST folder, and selecting the Outlook.pst file.

However, just after I did that, searching in Outlook failed. The message “No matches found” displayed for anything I searched for. I then restarted the laptop and results started showing up when I search in my Inbox, but the results are partial. When I search in Contacts, no results show up.

What is happening now and how can I fix it?
Regards,

JMT

User avatar
HansV
Administrator
Posts: 78378
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Cause the Contacts "File as" fields to correspond to "Na

Post by HansV »

Which version of Windows are you using?
Best wishes,
Hans

jmt356
SilverLounger
Posts: 2381
Joined: 28 Mar 2010, 01:49

Re: Cause the Contacts "File as" fields to correspond to "Na

Post by jmt356 »

Windows 8
Regards,

JMT

User avatar
HansV
Administrator
Posts: 78378
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Cause the Contacts "File as" fields to correspond to "Na

Post by HansV »

If you're on the desktop, click the Start button to activate the Start sceen.
Type Indexing, then click on Indexing Options among the search results (it's probably the only one).
Check whether indexing is complete.
Also check whether Outlook is listed. If not, click Modify.
Make sure that Outlook is selected, then click OK.
Best wishes,
Hans