Solved

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

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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Are you unable to connect or configure Hotmail email account in Microsoft Outlook 2010, 2007? Or Outlook.com emails are not downloading to Outlook? Lets’ see the problem and resolve Outlook Connector error syncing folder hierarchy (0x8004102A).
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…

856 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