Solved

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

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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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 …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

707 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

12 Experts available now in Live!

Get 1:1 Help Now