Become a Columnist Microsoft Exchange Site Microsoft Support SiteMSDN Exchange Site

   

Subscribe to OutlookExchange
Anderson Patricio
Ann Mc Donough
Bob Spurzem
Brian Veal
Catherine Creary
Cherry Beado
Colin Janssen
Collins Timothy Mutesaria
Drew Nicholson
Fred Volking
Glen Scales
Goran Husman
Guy Thomas
Henrik Walther
Jason Sherry
Jayme Bowers
John Young
Joyce Tang
Justin Braun
Konstantin Zheludev
Kristina Waters
Kuang Zhang
Mahmoud Magdy
Martin Tuip
Michael Dong
Michele Deo
Mitch Tulloch
Nicolas Blank
Pavel Nagaev
Ragnar Harper
Ricardo Silva
Richard Wakeman
Russ Iuliano
Santhosh Hanumanthappa
Steve Bryant
Steve Craig
Todd Walker
Tracey J. Rosenblath
 
 

I manipulated the FileAs field in a similar way to make it useful for my project. I used the following VB Script code. By approaching the problem this way you can keep names only the FullName field and just manipulate the FileAs field. This code is pretty flexible and can be modified to suit your individual needs. I also wrote a script to step through all of my existing contacts and perform this routine.

--Mort O'Sullivan
(tarwater@brew-master.com)

When placed in the VB Script Code portion of a Contact form, the following code will change the FileAs field whenever the contact's name or company name is changed. The formatting of the FileAs field follows thefollowing rules:

  1. If there is a company name, first name, and last name, then FileAs =Company Name (Last Name, First Name)
  2. If there is only a company name, then FileAs = Company Name
  3. If there is no company name, then FileAs = Last Name, First Name
  4. If there is only one name given (either First or Last), then a comma will not be used to separate the FirstName and LastName fields
  5. The middle name or initial will never be used in the FileAs field

This code is pretty flexible and can be modified to suit your individual needs. I also wrote a script to step through all of my existing contacts and perform this routine.

'***************************************************************************

'* Procedure: item_propertychange(name)
'* Description: Formats FileAs field when company or name field is changed

'***************************************************************************

Sub Item_PropertyChange(Name)
select case Name
case "CompanyName" ,"LastNameAndFirstName" ,"LastName" ,"FirstName" ,"CompanyAndFullName" ,"FullNameAndCompany" ,"MiddleName"
setfileas item
'msgbox item.parent.items.count
case else
'msgbox name 'debugging line
end select
End Sub

Sub SetFileAs(theItem)
dim sFileAs
sFileAs=FormatName(theitem.FirstName, theitem.LastName)
if theitem.companyname <>"" then
if sfileas <>"" then
sfileAs=theitem.companyname & " (" & sfileas & ")"
else
sfileas=theitem.companyname
end if
end if
theitem.fileas=sfileas
end sub

function FormatName (First, Last)
formatname=Last
if Last<>"" and first<>"" then formatname=formatname & ", "
formatname=formatname & first
end function

 


Disclaimer: Your use of the information contained in these pages is at your sole risk. All information on these pages is provided "as is", without any warranty, whether express or implied, of its accuracy, completeness, fitness for a particular purpose, title or non-infringement, and none of the third-party products or information mentioned in the work are authored, recommended, supported or guaranteed by Stephen Bryant or Pro Exchange. OutlookExchange.Com, Stephen Bryant and Pro Exchange shall not be liable for any damages you may sustain by using this information, whether direct, indirect, special, incidental or consequential, even if it has been advised of the possibility of such damages.

Copyright Stephen Bryant 2008