Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to change Outlook 2007's 'File As' options

Posted on 2011-02-25
1
Medium Priority
?
363 Views
Last Modified: 2012-05-11
Hey everyone!
I want to change two things, first i want to add a file as option for when making contacts.
Currently they give you options for,
First-name Last-name
Last-name, First-name
Last-name, First-name (Company)
(Company) Last-name, First-name

The one i want to build is First-name, Last-name (Company)

I am assuming it will be a vbscript, but i just need some direction. not knowing the fields puts a damper on me writing it my self.

Thanks!
- JesNoFear
0
Comment
Question by:JesNoFear
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 2

Accepted Solution

by:
JesNoFear earned 0 total points
ID: 34978018
I figured it out....

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)

End Sub

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
            ' 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
                If .CompanyName <> "" And .FirstName <> "" Then
                    strFileAs = .FirstName & " " & .LastName & " (" & .CompanyName & ")"
                ElseIf .CompanyName <> "" And FirstName = "" Then
                    strFileAs = .CompanyName
                ElseIf .Title <> "" Then
                    strFileAs = .Title & .FirstName & " " & .LastName
                Else
                    strFileAs = .FirstName & " " & .LastName
                End If
               
               .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
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you troubleshoot Outlook for clients, you may want to know a bit more about the OST file before doing your next job. IMAP can cause a lot of drama if removed in the accounts without backing up.
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question