Solved

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

Posted on 2011-02-25
1
355 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
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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

This process describes the steps required to Import and Export data from and to .pst files using Exchange 2010. We can use these steps to export data from a user to a .pst file, import data back to the same or a different user, or even import data t…
Following basic email etiquette rules will help you write a professional email and achieve a good, lasting impression with your contacts.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
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 …

863 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now